Welcome Guest, Not a member yet? Register   Sign In
DataMapper 1.6.0

[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?

[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. ;-)

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

[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!

[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.

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

[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?

[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!

[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

[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.




Theme © iAndrew 2016 - Forum software by © MyBB