[eluser]Jelmer[/eluser]
This might be a stupid question but I can't for the life of me figure out how to search this in Google or PHP.net and not get loads of (and as far as I can see: only) results I don't want.
I got a function that ends in:
Code:
$output = array();
$result = $this->db->get()->result_array();
foreach ($result as $row)
{
$output[] = new self($row);
}
// Return array of objects
return $output;
This is from a CRUD/ORM like library I wrote that extends the basic CI model.
Each of my models extens the replacement model. When I ask it for multiple entries I want them to be returned as objects so I can use them as such. The problem is when I call this function from a child class it returns objects of the parent kind. How do I perform the "new self();" and make it refer to the class it's called from and not to the parent?
The function itself is a public function by the way, not static.
(I'll release this library once it works, but right now it's still too full of bugs to be released)