Cakephp Autoconvert find() fields?
Posted
by
Razor Storm
on Stack Overflow
See other posts from Stack Overflow
or by Razor Storm
Published on 2011-01-15T04:49:14Z
Indexed on
2011/01/15
4:53 UTC
Read the original article
Hit count: 155
In cake php I can grab a model's fields by using the find() method. What if I wish to apply a transformation function to the fields? Is there a way to directly accomplish this task?
Suppose I have a model called RaceTime
with the fields racerId
and timeMillis
RaceTime
+------------+
| Field |
+------------+
| id |
| racerId |
| timeMillis |
+------------+
timeMillis is an int specifying how long the race took in milliseconds. Obviously saying a race took 15651 milliseconds isn't very useful to a human reader, and I would wish to convert this to a human readable format.
Is there a way to accomplish this directly in find()?
Or is the only option to loop through the results after find() finishes?
© Stack Overflow or respective owner