Data_SQL Function prefix turn an object to an array but key can have a prefix
This commit is contained in:
parent
5eb7c71b0d
commit
b227bac71a
1 changed files with 5 additions and 4 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue