如何将其转换为 codeigniter 查询样式?
how to convert this to codeigniter query style?
SELECT `users`.`first_name`, `user_profile`.`user_id`,
`user_profile`.`image`, `messages`.* FROM `messages` LEFT JOIN `user_profile` ON
`user_profile`.`user_id` = `messages`.`from_id` LEFT JOIN `users`ON `users`.`id`
= `messages`.`from_id` WHERE (messages.delete_from != '9' AND messages.delete_to
!='9’) AND ( `messages`.`members` = '4,9' OR `messages`.`members` = '9,4' )
ORDER BY `date` ASC
$this->db->from($this->table);
$this->db->select('users.first_name,user_profile.user_id,user_profile.image,messages.*');
$this->db->join('user_profile', 'user_profile.user_id = messages.from_id','left');
$this->db->join('users', 'users.id = messages.from_id','left');
$this->db->where($id1);
$this->db->where($id2);
$this->db->group_start();
$this->db->where('messages.members',$con1);
$this->db->or_where('messages.members',$con2);
$this->db->group_end();
$this->db->order_by('date','asc');
使用 $this->db->group_start();
和 $this->db->group_end();
作为括号
SELECT `users`.`first_name`, `user_profile`.`user_id`,
`user_profile`.`image`, `messages`.* FROM `messages` LEFT JOIN `user_profile` ON
`user_profile`.`user_id` = `messages`.`from_id` LEFT JOIN `users`ON `users`.`id`
= `messages`.`from_id` WHERE (messages.delete_from != '9' AND messages.delete_to
!='9’) AND ( `messages`.`members` = '4,9' OR `messages`.`members` = '9,4' )
ORDER BY `date` ASC
$this->db->from($this->table);
$this->db->select('users.first_name,user_profile.user_id,user_profile.image,messages.*');
$this->db->join('user_profile', 'user_profile.user_id = messages.from_id','left');
$this->db->join('users', 'users.id = messages.from_id','left');
$this->db->where($id1);
$this->db->where($id2);
$this->db->group_start();
$this->db->where('messages.members',$con1);
$this->db->or_where('messages.members',$con2);
$this->db->group_end();
$this->db->order_by('date','asc');
使用 $this->db->group_start();
和 $this->db->group_end();
作为括号