I want to know if there’s a way to filter the result from ORM. I wish to create a custom method to my Model, for example, one to filter the output from my Data Base. Right now, only is possible to filter the data from the POST in a form to save them into a Data Base, but, I want the opposite.
If I have one field on my table called “identification” with the value “8-985-256”, I want that value as “08-0985-00256” (don’t worry about how to add the extra zeros, that part is easy).
Let’s say that I have a custom method on my Model called “format_identification”.
Then, I get the data using the ORM class like so:
$user = ORM::factory('user', 1);
I want to echo the identification, but, with the correct format:
echo $user->format_identification();
This should print “08-0985-00256”. If I use the name of the field, that works, but, the format of the value not.
I hope you understand what I’m trying to do.
Thank you for your time.
Add public method to your
Model_Userfile calledformat_identificationlike: