CodeIgniter Forums
Datamapper ORM v 1.80 huge Array - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Datamapper ORM v 1.80 huge Array (/showthread.php?tid=41430)



Datamapper ORM v 1.80 huge Array - El Forum - 05-07-2011

[eluser]da_mage[/eluser]
Hi,
I'm using Datamapper ORM v 1.80.
And realised that it returns a huge array

here is my code:

Code:
$user= new User('id',1);
    print_r($user);
    die('ok');

Im searching only for the user with id 1
The table Users has about 15 fields
and at this moment there are only 2 records inside the table.
yet it will return a page or two long full of array objects.
I can see that amongst the array objects is also my codeigniter main config file?? and datamappers config Items..


Datamapper ORM v 1.80 huge Array - El Forum - 05-07-2011

[eluser]WanWizard[/eluser]
Try to understand how PHP, and CodeIgniter work.

In PHP5, all objects are assigned by reference. This means that although you see them when you access a Datamapper object, they are not copies, and don't take up memory.

CodeIgniter works by assigning all objects as singletons to $this, so a var_dump($this) will show you pages and pages of object information. All other objects that access CI ( either via an automatic mechanism or through get_instance() ) use references.

So obviously you'll see all this when you dump a Datamapper object. Because Datamapper accesses the database, language, and form validation libraries, which in turn have links to several other libraries.


Datamapper ORM v 1.80 huge Array - El Forum - 05-07-2011

[eluser]da_mage[/eluser]
WOW...Thank you for claryfing this WanWizard.
and for your super quick reply.
I thought I was doing something wrong ...
you're the bestSmile
now I can happily get back to coding againSmile
Tnx.