【问题标题】:Threaded Messaging System线程消息系统
【发布时间】:2011-09-13 21:39:55
【问题描述】:

正在构建一个线程消息传递系统,我有以下表格

conversations_inbox
id
R_id
S_id
message
read
post_time
conv_id

conversation_outbox 
id
R_id
S_id
message
read
post_time
conv_id

conversation_meta
id
sender_id
reciever_id
datetime

conversations_inboxconversation_outbox 有一个外键 conv_id,它跟踪两个用户之间的消息传递线程 我在处理消息收件箱时遇到了问题,我试图通过sender_id(S_id) 对收件箱中的消息进行分组,而不是将用户收到的每条新消息都显示为新行。所以框中给用户的所有消息都是分组在发送它的用户下,并显示来自该用户的最新消息。

我试过了

function get_user_conversations($user_id) {
       //Load Models
       $this->load->model('conversation_model');
       //Load helper
       $this->load->helper('date');
       //database query
       $q = $this->db->select('R_id,message,post_time,read,conv_id')
                     ->from('conversations_inbox')
                     ->where('R_id',$user_id)
                     ->group_by('S_id')
                     ->order_by('post_time','desc')
                     ->get();
        $conversations = $q->result();
        return $conversations;
   }

但它只为每个 Sender id 返回一行数据 如果有人能指出我正确的方向,我将不胜感激

【问题讨论】:

    标签: php mysql codeigniter


    【解决方案1】:

    首先我要声明的是,在此之前我从未听说过 codeigniter...

    我在想这是因为你在group_by 之后调用->order_by('post_time','desc'),尝试切换这两个,在它们未分组时对其进行排序是这样的想法......

    Just found this forum with a similar problem

    【讨论】:

      猜你喜欢
      • 2013-01-10
      • 1970-01-01
      • 1970-01-01
      • 2011-09-26
      • 2010-11-13
      • 2012-02-02
      • 1970-01-01
      • 1970-01-01
      • 2011-01-18
      相关资源
      最近更新 更多