PHP Classes

Object return

Recommend this page to a friend!

      Simple MySQL handler  >  All threads  >  Object return  >  (Un) Subscribe thread alerts  
Subject:Object return
Summary:Arrays from execute() work better than objects
Messages:2
Author:Gerry Danen
Date:2016-03-29 20:19:58
 

  1. Object return   Reply   Report abuse  
Picture of Gerry Danen Gerry Danen - 2016-03-29 20:19:58
I am using this method to convert objects from the execute method to arrays.

It may enhance the dbase class.


private(or public) function _objectToArray($objectIn)
{
$arrayOut = array();
if ( $objectIn )
{
foreach ( $objectIn AS $key => $item )
{
if ( is_array($item) OR is_object($item) )
{
$arrayOut[$key] = $this->_objectToArray($item);
}
else
{
$arrayOut[$key] = $item;
}
}
}
return $arrayOut;
}

  2. Re: Object return   Reply   Report abuse  
Picture of Matthew Boyle Matthew Boyle - 2016-03-29 20:40:07 - In reply to message 1 from Gerry Danen
Thanks for the suggestion. That's a clever function.