CodeIgniter Forums
DataMapper 1.6.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 1.6.0 (/showthread.php?tid=11358)



DataMapper 1.6.0 - El Forum - 10-29-2008

[eluser]steelaz[/eluser]
I understand when updating a record DM will run query only against the fields that changed. Is there a method in DM to determine what those fields are. I want to log fields that changed (field: old_value -> new value). I could write this in a controller but maybe DM has something to offer?


DataMapper 1.6.0 - El Forum - 10-29-2008

[eluser]OverZealous[/eluser]
The method is a private one, called _changed($field). You simply call it with the name of the field BEFORE you save, and it checks against the database.

Note, however, that it runs a small query against the DB for each field to determine if it has changed. It may be a performance problem.

Also, since it is a private method, there is no guarantee it won't work differently, or be removed altogether, in a future version. ;-)


DataMapper 1.6.0 - El Forum - 10-29-2008

[eluser]steelaz[/eluser]
Thanks for the tip, that's exactly what I was looking for.


DataMapper 1.6.0 - El Forum - 10-29-2008

[eluser]Boyz26[/eluser]
For performance purposes, should I index both columns in the join_tables (eg. employee_id and company_id in table join_employee_company)?

Thanks!


DataMapper 1.6.0 - El Forum - 10-29-2008

[eluser]OverZealous[/eluser]
I don't know about your database engine, but I've always been told that, unless you are dealing with <i>really</i> big tables, the database engine usually doesn't even use the indexes.

IE: you can add the indexes, but they add a cost when writing that might not be beneficial during reads.


DataMapper 1.6.0 - El Forum - 10-29-2008

[eluser]Boyz26[/eluser]
You replied in two minutes! Sweet! Go CI community!


DataMapper 1.6.0 - El Forum - 11-01-2008

[eluser]Aukie[/eluser]
I am auto loading the datamapper model as explained in the first page of this post. But doing so gives me the error:

Code:
The model name you are loading is the name of a resource that is already being used: datamapper

Can any body explain me what happend?


DataMapper 1.6.0 - El Forum - 11-01-2008

[eluser]Matthew Lanham[/eluser]
Just wanted to say this is a fantastic contribution, the documentation is brilliant (which makes all the difference) and the functionality and cleanness of how it works is brilliant, this functionality is something that was an advantage for CakePHP when i had a dabble in it, so keep up the good work!


DataMapper 1.6.0 - El Forum - 11-01-2008

[eluser]OverZealous[/eluser]
@Aukie
The latest release of DataMapper is a Library. It therefore needs to be autoloaded as a Library, as well, but not loaded as a model now.

The DataMapper documentation has this updated better: http://stensi.com/datamapper/pages/installation.html


DataMapper 1.6.0 - El Forum - 11-01-2008

[eluser]Aukie[/eluser]
[quote author="OverZealous.com" date="1225566474"]@Aukie
The latest release of DataMapper is a Library. It therefore needs to be autoloaded as a Library, as well, but not loaded as a model now.

The DataMapper documentation has this updated better: http://stensi.com/datamapper/pages/installation.html[/quote]

Thanks OverZealous,
I made a little mistake thats why it did not work and looking for solutions found out in this forum I had to load datamapper as model...

Thanks, datamapper looks cool, let's see if it is indeed a realy big advantage.