CodeIgniter Forums
DataMapper ORM v1.8.0 - 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 v1.8.0 (/showthread.php?tid=37531)



DataMapper ORM v1.8.0 - El Forum - 04-11-2011

[eluser]rherriman[/eluser]
Understood.

For the record, calling clear() was not a solution. Smile It annihilated the object entirely, it seems, as I could not chain anything afterwards. A means to reset the query in-progress might be useful in more situations than my own!

For now though, I have resigned myself to simply grabbing the whole tree. I'm not using dump_tree, though. The model has some useful utility methods (such as providing a permalink) that would be lost to me if I let it be converted to an array. So, I went with this:

Code:
$category_list = new Category();
$category_list->select_depth()->select('*')->get();

I had to chain it in this order, because if I select('*')'d first, that statement would find its way into the subquery and break it (argh).


DataMapper ORM v1.8.0 - El Forum - 04-11-2011

[eluser]j4zzyh4ck3r[/eluser]
Did CI don't have ORM embedded inside ? Is it a different part from CI ?


DataMapper ORM v1.8.0 - El Forum - 04-12-2011

[eluser]WanWizard[/eluser]
No, it doesn't. It has something called ActiveRecord, which (in the strict definition) is not ActiveRecord, but more of a query builder.


DataMapper ORM v1.8.0 - El Forum - 04-12-2011

[eluser]j4zzyh4ck3r[/eluser]
[quote author="WanWizard" date="1302628370"]No, it doesn't. It has something called ActiveRecord, which (in the strict definition) is not ActiveRecord, but more of a query builder.[/quote]

What the different with CI's active record ? Is ORM is better solution for models ?


DataMapper ORM v1.8.0 - El Forum - 04-12-2011

[eluser]WanWizard[/eluser]
CI's active record is a query builder, it's an aid to construct a traditional query, so
Code:
// standard sql
$result = $this->db->query('SELECT this, that FROM here WHERE this = "something" ORDER BY that ASC');

// AR
$result = $this->db->select('this, that')->from('here')->where('this', 'something')->order_by('that', 'ASC')->get();
As you can see, quite similar.

ORM's on the other hand are object based, where every record is an object, every result a collection of objects, and objects can have relations. In an ORM, you access the database though it's object models.

For Datamapper ORM, http://datamapper.wanwizard.eu/pages/gettingstarted.html gives a good overview of how you configure your models, and how to use them in your controllers.


DataMapper ORM v1.8.0 - El Forum - 04-12-2011

[eluser]j4zzyh4ck3r[/eluser]
[quote author="WanWizard" date="1302646270"]CI's active record is a query builder, it's an aid to construct a traditional query, so
Code:
// standard sql
$result = $this->db->query('SELECT this, that FROM here WHERE this = "something" ORDER BY that ASC');

// AR
$result = $this->db->select('this, that')->from('here')->where('this', 'something')->order_by('that', 'ASC')->get();
As you can see, quite similar.

ORM's on the other hand are object based, where every record is an object, every result a collection of objects, and objects can have relations. In an ORM, you access the database though it's object models.

For Datamapper ORM, http://datamapper.wanwizard.eu/pages/gettingstarted.html gives a good overview of how you configure your models, and how to use them in your controllers.[/quote]

So it is like LinQ, right ?


DataMapper ORM v1.8.0 - El Forum - 04-13-2011

[eluser]WanWizard[/eluser]
I had to look that up, I've never heard of LinQ. Logical, me and MS are not compatible. Wink


DataMapper ORM v1.8.0 - El Forum - 04-13-2011

[eluser]Kestutis S.[/eluser]
Hello,
I just upgraded CI to 2.0.2 and got an error that "table 'Whatever' not found", it can not find the table because it's name is with first letter upper case, so the problem is that CI changed inflector helper and in plural() they don't use strtolower function anymore.
This can be fixed with changing datamapper library file near 550 line: instead of $this->table = plural(get_class($this)); use $this->table = plural($this_class);.
If there is a better solution I would like to hear it.

Thanks WanWizard for the great library.


DataMapper ORM v1.8.0 - El Forum - 04-13-2011

[eluser]WanWizard[/eluser]
Datamapper includes it's own inflector helper (to overcome some other issues as well), make sure you have installed that in your application/helper directory,


DataMapper ORM v1.8.0 - El Forum - 04-13-2011

[eluser]Syahzul[/eluser]
Hi, is there any complete example for nestedsets? any code you can point me on how to use it. i have read the user guide, but still not fully understand how to use it.

thank u in advanced.