From b227bac71a8339b35b24717586692ef57fa0024c Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 24 Nov 2019 20:41:10 +0100 Subject: [PATCH] Data_SQL Function prefix turn an object to an array but key can have a prefix --- include/lib/noalyss_sql.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/lib/noalyss_sql.class.php b/include/lib/noalyss_sql.class.php index 1eb466d3b..25edb2f57 100644 --- a/include/lib/noalyss_sql.class.php +++ b/include/lib/noalyss_sql.class.php @@ -312,16 +312,17 @@ abstract class Noalyss_SQL extends Data_SQL return $this; } /** - * Turn an object (row) into an array + * Turn an object (row) into an array, and the key could be prefixed with $prefix + * @param string $prefix before the key * @return array */ - public function to_array() + public function to_array($prefix="") { $array=array(); foreach ($this->name as $key=> $value) { - - $array[$key]=$this->$key; + $nkey=$prefix.$key; + $array[$nkey]=$this->$key; } return $array; }