gpt4 book ai didi

cakephp - 如何在 cakephp 连接数组中写入顺序和限制

转载 作者:行者123 更新时间:2023-12-02 01:49:30 25 4
gpt4 key购买 nike

我在 cakephp 中加入如下:

$emp = $this->EmployeePersonal ->find(
'all',
array(
'fields' => array('EmployeePersonal.*', 'PermanentDist.name','PresentDist.name','EmployeePosting.*','Designation.name','Department.name','Office.name' ),
'conditions' => $condition,
'order' => array('Designation.id'),
'recursive' => -1,
'joins' => array(
array(
.................
.................
),

array(
'table' => 'employee_postings',
'alias' => 'EmployeePosting',
'type' => 'LEFT',
'order' => 'EmployeePosting.posting_from DESC',
'limit' => 1,
'conditions' => array(
'EmployeePosting.employee_personal_id = EmployeePersonal.id',
)
),
)
)
);

但是线条

'order' => 'EmployeePosting.posting_from DESC',
'limit' => 1,

不工作!这意味着虽然我期望获得最新的 posting_from 值,但我得到了所有值!我哪里做错了?我想我把 order limit 写错了地方。

最佳答案

要获取最新的 posting_from,您必须使用 'group_by' => 'employee_personal_id' 而不是 'limit' => '1''order' => 'EmployeePosting.posting_from DESC' 将在同一个数组中保持不变。

关于cakephp - 如何在 cakephp 连接数组中写入顺序和限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23676451/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com