Thursday, March 24, 2011

Re: Problem Joining table

On Fri, Mar 25, 2011 at 9:33 AM, thom <cyber.phantom79@gmail.com> wrote:
>>
>> Perhaps you need to unBind() the other associations and then add those
>> joins to $paginate, as well.
>>


Here is my code :


$this->Expense->unbindModel(array('belongsTo' => array('Visit',
'Tariff', 'Worker')),false);

$this->paginate = array(
'Expense' => array(
'joins' => array(
array(
'table' => 'visits',
'alias' => 'Visit',
'type' => 'LEFT',
'conditions' => array(
'Visit.id = Expense.visit_id'
)
),
array(
'table' => 'tariffs',
'alias' => 'Tariff',
'type' => 'LEFT',
'conditions' => array(
'Tariff.id = Expense.tarif_id'
)
),
array(
'table' => 'workers',
'alias' => 'Worker',
'type' => 'LEFT',
'conditions' => array(
'Worker.id = Expense.worker_id'
)
),
array(
'table' => 'poschecks',
'alias' => 'Poscheck',
'type' => 'LEFT',
'conditions' => array(
'Poscheck.id = Visit.poscheck_id'
)
),
array(
'table' => 'grouptariffs',
'alias' => 'Grouptariff',
'type' => 'LEFT',
'conditions' => array(
'Grouptariff.id = Tariff.grouptarif_id'
)
)
),
'conditions' => "Visit.tanggal >= '2011-03-01' AND Visit.tanggal
<= '2011-03-31'",
'limit' => 10
)
);

$data = $this->paginate('Expense');
$this->set('patients', $data);


Why is my 'join' not works in this case?
It just unbind the model and paginate it.. I just wonder why. Anyone can help?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: