Usually I create lists for using with $form->select(), vía
find('list') method. For instance, in the controller method
$l = $this->ProductCategory->find('list');
Another way to create the list is by using a plain query:
$l = $this->ProductCategory->query('SELECT `id`, `name` FROM
product_categories ORDER by `name` ASC');
The problem is that select is not correctly rendered when I need a SQL
calculated field. My trouble is the following:
The table "product_categories" has a field called "sex" with type
VARCHAR(1) and whose values are 'M' or 'F'. I need that in my select,
the list items apear of the following manner:
Pants(WOMEN)
Shirts (WOMEN)
Pants (MEN)
Shirts (MEN)
...
I try to create the list with the following query:
$query = "SELECT `id`, CONCAT(`name`,IF(`sex`= 'M','(MEN)','(WOMEN)'))
AS `description` from `product_categories` ORDER BY `name` ASC, `sex`
ASC;";
$l = ProductCategory->query($query);
But the calculated field appears wrapped into an array and the select
list wouldn't create correctly.
How to make a "raw query" in order to add SQL calculated fields?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---