I have searched high and low for an answer to this question...

I have a 1 to 1 relationship in my database.

A Restaurant has one Coupon

The coupon is optional, so the restaurant without coupons should be
included in the result set, however, when I try to sort by restaurants
that have a coupon first, then by Restaurant Name ASC, restaurants
without coupons are mixed in the results. I would like to sort by the
following:

Sort by whether or not restaurant has a coupon (yes before no)
Sort by Restaurant Name ASC

So all coupon results first A-Z and then all non-coupon restaurants A-
Z.

The best I could do is sort by Coupon.id DESC, but the sort should be
by Whether they have a coupon or not, and then by restaurant name.
Here is my controller paginate var. :

var $paginate = array(
        'Restaurant' => array(
            'limit' => 50, 'page' => 1,
            'order' => array('Coupon.id' => 'DESC',
'Restaurant.tier'=>'ASC', 'Restaurant.name' => 'ASC'),
            'contain' => array('Address', 'Coupon'),
            'fields' => array(
                'Restaurant.id', 'Restaurant.name', 'Restaurant.tier',
'Coupon.id', 'Coupon.restaurant_id', 'Coupon.value', 'Coupon.type',
'Coupon.restaurant_tier', 'Coupon.restaurant_name',
'Coupon.description','Coupon.terms','Coupon.title','Coupon.exp_date',
                'Address.*',
            ),
            'recursive' => 0,
        )
    );

--~--~---------~--~----~------------~-------~--~----~
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