我有两张表maintenance_owner
,maintenance_users
下面是我的表结构 这是维护用户表
这是维护所有者表
现在我可以使用此代码获取所有用户
$this->db->select('mu.*, mo.id_land_owner as mu_owner, mo.group_name, mo.id_mu');
$this->db->from('maintenance_users as mu');
$this->db->join('maintenance_owner as mo','mu.id_maintenance = mo.id_mu');
$this->db->where('mo.id_land_owner', $land_owner_id);
return $this->db->get()->result();
它返回
[0] => stdClass Object
(
[id_maintenance] => 170
[full_name] =>
[username] => abt2050+m3@gmail.com
[password] =>
[token] => 914c001251a1ab018e5eb51923e8f6cc
[mu_owner] => 152
[group_name] => Cleaner
[id_mu] => 170
)
[1] => stdClass Object
(
[id_maintenance] => 176
[full_name] =>
[username] => bii@fatafati.net
[password] =>
[token] => 579faa456520656fcc24be047ca6a3bf
[mu_owner] => 152
[group_name] =>
[id_mu] => 176
)
[2] => stdClass Object
(
[id_maintenance] => 175
[full_name] =>
[username] => iamnow78+m4@gmail.com
[password] =>
[token] => d2f6b180a6a7bb32ecd26ffe0297f8f5
[mu_owner] => 152
[group_name] =>
[id_mu] => 175
)
但我需要得到这样的结果
[0] => stdClass Object
(
[id] => 30
[id_land_owner] => 152
[group_name] => Cleaner
[group_users] => abt2050+m1@gmail.com,abt2050+m2@gmail.com,abt2050+m3@gmail.com,abt2050+m4@gmail.com
)
[1] => stdClass Object
(
[id] => 29
[id_land_owner] => 152
[group_name] => Gardener
[group_users] => abt2050+a1@gmail.com,abt2050+a2@gmail.com,abt2050+a3@gmail.com
)
只需要使用 sql 查询来执行此操作我正在使用 codeigniter fraework