Hi:
I am new to cakephp and so far I am getting along. However, I am
having problems using the sorting capabilities of the paginate class.
This is the situation:
I have a record set with some records having null values in the
address field. When I sort by address asc and desc I create an alias
field called 'no_value' with a 1 if there's an address and 0 if there
isn't one so that i can use the 'no_value' field in the ORDER BY
statement and force all records with an address to always appear at
the top.
Here's how I build the alias in the model's fields option:
'IF (FieldValue.value IS NULL, IF(FieldValue.value = "",1,0), 1) AS
no_value'
Then in paginate I do this:
'order' => array('no_value'=>'desc', 'FieldValue.value'=> 'asc')
This works fine when the list shows the first time, but when the order
link is clicked the pagination ordering uses only the address value
and not the 'no_value'. Is there any way of putting back the
'no_value' in the ORDER BY statement before the query is processed or
is there some other way to do this?
Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---