0
我使用分頁組件,用於在cakephp3排序如何使用加入模型中CakePHP的排序3
<?php echo $this->Paginator->sort('field');?>
在模型中我也加入了多種型號
$this->table('orders');
$this->primaryKey('order_id');
$this->hasMany('Customers');
$this->belongsTo('Customers', [
'foreignKey' => 'fk_customerid',
'joinType' => 'LEFT',
'dependent' => true,
]);
$this->hasMany('Users');
$this->belongsTo('Users', [
'foreignKey' => 'fk_userid',
'joinType' => 'LEFT',
'dependent' => true,
]);
在控制器 - >公共職能指數有
$getOrders = $this->Orders->find('all')
->contain([
'Customers' => function ($q) {
return $q
->select(['customer_name']);
},
'Users' => function ($q) {
return $q
->select(['firstname','lastname']);
}
])
->limit($this->per_page);
然後如何使用paginate組件設置客戶名稱的排序。感謝
感謝兄弟公司工作的罰款 –