Data_SQL Function prefix turn an object to an array but key can have a prefix

This commit is contained in:
Dany De Bontridder 2019-11-24 20:41:10 +01:00
parent 5eb7c71b0d
commit b227bac71a

View file

@ -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;
}