Search code examples
phpcakephpmodelingres

additionals properties of a model in cakephp?


I'm starting to use cakePhp and I would like to know:

When I do a query(like with $this->Product->find(...)), I receive an array, right?

Then: -If I've some non-db fields with default values that I've to display for each product, how do I do?

I saw virtual fields, but I cannot manage to put a static var into it


Solution

  • You can use the solution Anh Pham provided another thing you could do, if it's just setting the values to display them, is add them to the array in your controller after you have the results:

    $result['Model']['desired_field_name'] = $static_field;