我有一个在 codeigniter 中开发的网站,我想在其中检索特定 tee 的评论。我有一个像这样的 T 恤:
- id
- user_id
- name
- created
- modified
像这样的表 tee_comments:
- id
- user_id
- tee_id
- created
- modified
我已经完成了这个查询:
$this->db->select('*,tee.id as id,tee.created as created, tee_comments.id as tee_comments_id, tee_comments.created as tee_comments_created, tee_comments.modified as tee_comments_modified');
$this->db->from('tee');
$this->db->join('tee_comments', 'tee_comments.tee_id = tee.id','left outer');
$this->db->order_by("tee.created", "desc");
$query = $this->db->get();
通过此查询,我检索了两行 tee,因为我在该 tee 中有两条评论。
我的目标是只检索一行,其中有一组注释,例如:
tee{
id,
name,
created,
modified
comment{
[0]
id,
tee_id,
comment,
created,
modified
[1]
id,
tee_id,
comment,
created,
modified
}
}
我尝试过加入:-左-右-左外-右外
但是并没有解决问题,有没有办法做到这一点?谢谢