Welcome Guest, Not a member yet? Register   Sign In
DataMapper: modify values for each item after calling get()
#1

[eluser]felix_[/eluser]
Hey,
in my database I have stored a lot of objects with a start and end time exact to the second. Now the requirements changed and for calculation purposes I just need the data with seconds set to 0 but I don't want to modify the data the database itself.
So my idea was simply to modify the time string on creation of the object. This works well if I do retrieve the object directly via id.
Code:
$t = new Time(1337);

But when I load a collection the constructor of my model gets executed for every time but always with the value of the same item.

Code:
$t = new Time();
$t->where("user_id", 1337)->get();

So what is the best way to modify the values for ALL loaded items?

Felix
#2

[eluser]WanWizard[/eluser]
Use a get_rule to convert the value on read.




Theme © iAndrew 2016 - Forum software by © MyBB