We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to remove object _dependencyInjector in result findFirst

I can remove object _dependencyInjector in result findFirst?

object(Model\Core\Users)#109 (27) { ["id"]=> string(7) "58484234" ["uniqid"]=> NULL ["username"]=> string(24) "example" ["password"]=> string(60) "$2a$12$4aHc2vBkAB755JNc850LmeSPdcBMF3wQy3/YFDJ0hDWxvcssdfsdf" ["email"]=> string(24) "[email protected]" ["mobile"]=> string(11) "01677232941" ["status"]=> string(1) "3" ["block"]=> NULL ["del"]=> string(1) "0" ["convert_from"]=> NULL ["extend"]=> NULL ["created"]=> NULL ["updated"]=> string(19) "2016-08-10 12:04:24" ["_dependencyInjector":protected]=> object(Phalcon\Di\FactoryDefault)#23 (4) { ["_services":protected]=> array(33) { ["router"]=> object(Phalcon\Di\Service)#48 (5) { ["_name":protected]=> string(6) "router" ["_definition":protected]=> object(Closure)#47 (1) { ["static"]=> array(1) { ["config"]=> object(Phalcon\Config)#2 (9) { ["default"]=> string(6) "Sample" ["uniqueId"]=> string(39) "pj-de41dc25-d996-4c40-9818-61af1c3zxczxsda9"

But findFirst returns calss of some object. Phalcon is using ActiveRecord - this is why there is DI. If you want to return just data then use toArray(). Or type columns what you want.

You're dumping entire object from memory. That should not be the way to use Phalcon or OOP in general. You need to use public methods and properties to work with. As you can see from var_dump, object element _dependencyInjector is declared as protected. If you iterate through result set from findFirst(), you'll see only visible properties and objects from your actual data set from database.