如何在Zend Framework 3中使用GROUP_CONCT



假设我有一个表:organization_branches_custom_not_working_days

_________________________________________________________________________
|id   | created_at             | date        | organization_branch_id    |
_________________________________________________________________________
| 1   | 2020-03-01 21:42:05    | 2020-02-28  | 2                         |
| 2   | 2020-03-01 21:42:05    | 2020-02-28  | 2                         |
| 3   | 2020-03-01 21:42:05    | 2020-02-28  | 2                         |                  
| 4   | 2020-03-01 21:42:05    | 2020-02-28  | 1                         |
__________________________________________________________________________

使用此查询:

SELECT organization_branch_id, GROUP_CONCAT(date SEPARATOR ', ') FROM organization_branches_custom_not_working_days GROUP BY organization_branch_id;

您必须像一样use ZendDbSqlExpression

$select->columns(organization_branch_id, new Expression("GROUP_CONCAT(date SEPARATOR ', ')"));

最新更新