分组不显示在codeigniter数据表查询

时间:2016-06-28 09:26:36

标签: php mysql codeigniter join datatable

我正在尝试在数据表查询中使用group by,如下所示:

但是我打印的查询中没有出现分组。

数据表查询:

$this->datatables->select('banks_users.id,users.created_at,username');
$this->datatables->from('banks_users');
$this->datatables->join('users', 'banks_users.users_id = users.id', 'LEFT OUTER');
$this->datatables->join('banks', 'banks.id = banks_users.banks_id', 'LEFT OUTER');
$this->datatables->join('branches_agents', 'branches_agents.users_id = users.id');
$this->datatables->join('branches', 'branches.id = branches_agents.branches_id');
$this->datatables->join('banks_countries', 'banks_countries.banks_id = banks_users.banks_id', 'LEFT OUTER');
$this->datatables->join('countries', 'countries.id = banks_countries.countries_id', 'LEFT OUTER');
$this->datatables->where('users.user_type', 'bank');
$this->datatables->group_by('banks_users.id');
$data = json_decode($this->datatables->generate());

但它不考虑group by并生成如下查询:

SELECT COUNT(*) AS numrows
FROM banks_users
LEFT OUTER JOIN users ON banks_users.users_id = users.id
LEFT OUTER JOIN banks ON banks.id = banks_users.banks_id
JOIN branches_agents ON branches_agents.users_id = users.id
JOIN branches ON branches.id = branches_agents.branches_id
LEFT OUTER JOIN banks_countries ON banks_countries.banks_id = banks_users.banks_id
LEFT OUTER JOIN countries ON countries.id = banks_countries.countries_id
WHERE users.user_type = 'bank'

所以,有人请帮忙......

0 个答案:

没有答案