nwalke
nwalke

Reputation: 3209

cakephp pagination only sorting on some columns

I have the following code in a controller. I can sort by all fields except Claim.number and Payer.abbr. Anyone see why that might be?

$this->paginate = array(
    'fields' => array(
        'PaymentException.*', 'Procedure.id', 'Procedure.cpt',
        'Procedure.expected_amount', 'Procedure.allowed_amount', 'Procedure.difference_amount',
        'Claim.id', 'Claim.number', 'Payer.abbr'
    ),
    'limit' => 50,
    'joins' => array(
        array(
            'table' => 'procedures',
            'alias' => 'Procedure',
            'conditions' => array('Procedure.id = PaymentException.procedure_id')
            ),
        array(
            'table' => 'claims',
            'alias' => 'Claim',
            'conditions' => array('Claim.id = Procedure.claim_id')
        ),
        array(
            'table' => 'payers',
            'alias' => 'Payer',
            'conditions' => array('Payer.id = Procedure.payer_id')
        ),
        array(
            'table' => 'groups',
            'alias' => 'Groups',
            'conditions' => array('Groups.id = Claim.group_id')
        ),
    array(
        'table' => 'exception_workflow_logs',
        'alias' => 'ExceptionWorkflowLog',
        'conditions' => array('ExceptionWorkflowLog.exception_id = PaymentException.id')
    )
    ),
    'conditions' => $conditions
);

All of the fields have been done in the view like:

<?php echo $this->Paginator->sort('Claim', 'Claim.number'); ?>

I see them in the URL, but it never sorts by Claim.number or Payer.abbr. I don't see why that would be.

In my conditions array I have:

array
  0 => string 'Procedure.difference_amount < 0' (length=31)
  1 => string 'PaymentException.finalized IS NULL' (length=34)

Note that the conditions array stays the same even on the columns that sort properly.

Upvotes: 1

Views: 731

Answers (1)

dogmatic69
dogmatic69

Reputation: 7585

You cant use joins and containable together. You will need to remove the contain and use a join or fetch the records for the contain in a second query.

Upvotes: 1

Related Questions