In PHP, you can usually put an object in an array, for example:
class Car{} $car = new Car();
I have a custom MVC environment that I created, and I need a controller to get the ORM object from the model so that it can pass this view. So, I initialize my custom object:
$user = new User(2);
Now I want to put this custom object in the $data
array so that it can be passed to the view:
($ user-> data returns an ORM object)
$array['user'] = $user->data;
The problem is that after that I get the following error:
Object of class ORM could not be converted to string
What am I doing wrong? Is there something I'm missing?
Thanks for any help in advance.
Edit: here the data $ user-> is referenced, this is from the class User
constructor:
$this->data = ORM::for_table("users")->find_one($this->user_id);
(I use Idiorm as ORM)
source share