Hi,
I am trying to order by a calculation (in a pagination) but my
calculation is being backticked to death. I can't find a way to write
this so that is works.

I have:

var $paginate = array(
        'Modelname' => array(
                'fields'=>array(
                        'Modelname.id',
                        'Modelname.fieldname',
                        'Modelname.foreign_id',
                        'Modelname.foreign_id>0 AS result' // no matter what I 
put here I
get an sql syntax error
                ),
                'limit' => 10,
                'order' => 'result ASC, Modelname.fieldname ASC'
        )
);

This results in:
SELECT `Modelname`.`id`, `Modelname`.`fieldname`,
`Modelname`.`foreign_id`, `Modelname`.`foreign_id>0` AS `result`
FROM...

and about 10 other variations I have tried. If I just copy the query
and remove the badly placed backticks I get a working query. I just
can't figure out how to "trick" Cake into not messing with the
calculation. Doing simple SUM(somefield) AS some_sum has never caused
any problems but I have not been able to find a "function" in MySQL
that would do a simple "greater than" comparison.

thanks in advance
/Martin
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to