1

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.

4
  • Get the sql generated and make sure it's correct. Try running that query in phpmyadmin or another tool to see if it works.
    – tigrang
    Oct 15, 2012 at 21:13
  • Looking at the SQL output, it is not correct. I'm trying to sort by Claim.number and there is no ORDER BY in the output.
    – nwalke
    Oct 15, 2012 at 21:27
  • What is in $conditions array ? Oct 17, 2012 at 14:47
  • Updated question to include conditions array
    – nwalke
    Oct 17, 2012 at 14:51

1 Answer 1

1

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.

1
  • Sorry to remove the green check mark, but this actually doesn't work. I've removed the contain and made it a join, and I'm seeing the exact same thing. Anything I can do to debug?
    – nwalke
    Nov 15, 2012 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.