I am doing a search over multiple tables in the db and have created a
custom query for pagination using multiple joins. The query itself
works fine and returns the right results. The issue is that sort isn't
working on most of the columns. In fact, it only works on the fields
that are part of the original model or it's closely related models,
it's not working on the fields that are being joined 3 or 4 tables
down the line. Below is the call I am using, if someone can take a
look and see if they see anything, it would be most appreciated.

 $this->paginate = array(
        'fields' => array(
          'Code.code',
          'Code.pirated',
          'Code.disabled',
          'LicenseType.id',
          'LicenseType.name',
          'CodesRegistration.registration_id',
          'CodesRegistration.code_id',
          'Registration.id',
          'Registration.date',
          'Registration.licensee',
          'Registration.organization',
          'Registration.contact_email',
          'Product.id',
          'Product.name',
          'Version.id',
          'Version.name'),
        //'order' => $order,
        'joins' => array(
          array(
            'table' => '`license_types`',
            'alias' => '`LicenseType`',
            'type' => 'LEFT',
            'conditions' => array('LicenseType.id =
Code.license_type_id')),
          array(
            'table' => '`codes_registrations`',
            'alias' => '`CodesRegistration`',
            'type' => 'RIGHT',
            'conditions' => array('CodesRegistration.code_id =
Code.id')),
          array(
            'table' => '`registrations`',
            'alias' => '`Registration`',
            'type' => 'LEFT',
            'conditions' => array('Registration.id =
CodesRegistration.registration_id')),
          array(
            'table' => '`products`',
            'alias' => '`Product`',
            'type' => 'LEFT',
            'conditions' => array('Product.id =
Registration.product_id')),
          array(
            'table' => '`versions`',
            'alias' => '`Version`',
            'type' => 'LEFT',
            'conditions' => array('Version.id =
Registration.version_id'))
          ));

      $this->Code->unbindModel(array('belongsTo' => array
('LicenseType')), false);

      $results = $this->paginate($conditions);

This is in the codes controller, so sorting over Code.code works, but
sorting over Product.id doesn't. It doesn't even show up in the query
generated by the profiler.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to