-1

How can I implement this query in cakephp? I can't get the information from Users table.

    SELECT * FROM Manufacture LEFT JOIN Order ON Manufacture.order_id = Order.id
LEFT JOIN User ON Order.user_id = User.id;

Manufacture: id order_id

Order: id user_id

User: id name

class Manufacture extends AppModel {
    public $belongsTo = array(
        'Order' => array(
            'className' => 'Order',
            'foreignKey' => 'order_id'
        )
    );
}

class Order extends AppModel {
    public $belongsTo = array(
        'User' => array(
            'className' => 'User',
            'foreignKey' => 'user_id'
        ));
}

class User extends AppModel {

}

In controller:

$this->Paginator->settings = array( 'limit' => 15 ); 
$this->set('entities', $this->Paginator->paginate('Manufacture'));
IgorPr
  • 11
  • 3

1 Answers1

1

Read the join section of the official documentation. It comes with examples.

When you read that and still have questions let us know.

floriank
  • 25,546
  • 9
  • 42
  • 66