我使用3个表来存储聊天消息。第一个表为任务详细信息,第二个表为用户列表,另一个用于存储聊天消息。
我需要如下所示的结果。
$this->db->select('tm.task_number as taskno,tm.user_id as owner,tm.task_subject as subject,tm.task_mention_link as link,tm.task_module_key as key,ul.user_id as users,ul.task_users_type as type,tc.chat_id,tc.messages as msg,tc.chat_date_time as chat_time,tc.chat_updated as update,tc.deleted as deleted*');
$this->db->from("tasks_main as tm");
$this->db->join("tasks_users_list as ul","tm.task_number = ul.task_number","left");
$this->db->join("tasks_chat as tc","tc.task_number = ul.task_number",'right');
$this->db->where(array("tm.task_number"=>35,"ul.task_users_type<"=>3));
$query = $this->db->get();
$result = $query->result_array();
**task details (separate array)**
taskno
owner
subject
link
key
**users (separate array)**
users list by users
7
2
3
4
9
**chat messages (separate array)**
msg list
ttt
ttttt
tttttt
ttttttt
ttttttttt
ttttttttt