Welcome Guest, Not a member yet? Register   Sign In
Adding property to an object
#3

[eluser]xwero[/eluser]
You need to not only bind the new property to the row but you have to bind it to the array too.
Code:
$rows = $query->result();

foreach ($rows as $key=>$row)
{
   $rows[$key]->subpages = count( $this->find_($row->page_id) );
}
// php5 only
$rows = $query->result();

foreach ($rows as &$row)
{
   $row->subpages = count( $this->find_($row->page_id) );
}


Messages In This Thread
Adding property to an object - by El Forum - 03-16-2009, 09:35 AM
Adding property to an object - by El Forum - 03-16-2009, 09:39 AM
Adding property to an object - by El Forum - 03-16-2009, 09:41 AM
Adding property to an object - by El Forum - 03-16-2009, 09:49 AM



Theme © iAndrew 2016 - Forum software by © MyBB