This error reason is object hold many values?

Hi all!

[My Question]

"Is there the way to make the object that only holds the required values?"

For example, Getting only one user record. Like this,

$user = Users::findFirstById(3);
echo "<pre>";
var_dump($user);
echo "</pre>";

When dump this object,Many values are printed.

This object is holding many values, (even Other object values and SQL)

It seems to have all the referenced values that was seleted on current page .

So?

Sometimes, I met the error by memory_limit over This error's reason is object hold many values?

(This error generated on aws ec2. Not generated on windows10 xampp.)

Please help!!

use ->toArray() to dump only data.



3.0k
edited Apr '17

By the way, the object is holding that many properties because of the DI.

As Wojciech Slawski said, use ->toArray() to return only the result set.



688

Thanks Wojciech Ślawski !

use ->toArray() to dump only data. I will use toArray() on next time!



688
edited Apr '17

Hi! H Thanks !


By the way, the object is holding that many properties because of the DI.


wow, I met the error of memory_limit over.

Is this reason DI?

I changed php.ini =>memory_limit = -1

And

I restarted nginx & php-fpm.

But I met this error again...



3.0k

Yeah, probably because of the DI. Giving -1 to the memory_limit won't give you unlimited memory, you're still restricted. What is the full error message it's giving you? Do you have sufficient memory on the sever?

Hi! H Thanks !


By the way, the object is holding that many properties because of the DI.


wow, I met the error of memory_limit over.

Is this reason DI?

I changed php.ini =>memory_limit = -1

And

I restarted nginx & php-fpm.

But I met this error again...

Just do:

$user = Users::findFirstById(3)->toArray();
echo "<pre>";
var_dump($user);
echo "</pre>";


688

Hi! Very Very thank so much Wojciech Ślawski !!!