如何在 cakephp 中实现这个查询?我无法从用户表中获取信息。
SELECT * FROM Manufacture LEFT JOIN Order ON Manufacture.order_id = Order.id
LEFT JOIN User ON Order.user_id = User.id;
制造商:id order_id
订单:id user_id
用户:身份证姓名
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 {
}
在控制器中:
$this->Paginator->settings = array( 'limit' => 15 );
$this->set('entities', $this->Paginator->paginate('Manufacture'));