Nisarg Nisarg - 1 year ago 101
MySQL Question

Can not get second table value in inner join in CakePHP

I am working in CakePHP framework. I want to join two tables. So I have written query like below.

'fields' => array('Merchant.username'),
'conditions' =>array('')
echo "<pre>";

When I print the details, then it will give only deal table record. Here I also want Merchant.username.

So what would I have to change in the above query?

Note :- I am working with CakePHP version 1.3.13

Answer Source
$details = $this->Deal->find('all', array('joins' => array(
            'table' => 'merchants',
            'alias' => 'Merchant',
            'conditions' => array('')
    ), 'conditions' => array('' => $id),
    'fields' => array('Merchant.username', 'Deal.*'),
    echo "<pre>";