多维数组不返回所有MySQLi行

时间:2012-12-26 16:58:58

标签: php codeigniter

从下面的图片可以看出,我只在前端找到一排。我应该返回多行。有人知道我做错了吗?

enter image description here

public function chatBoxMembers() {
        $userid = $this->session->userdata('userid');
        $wow = $this->db->get_where('messages', array('messageRecipientId' => $userid));
        foreach($wow->result() as $row) {
            $imUser = array();
            $imUser['friendId'] = $row->messageSentById;
            $imUser['messageBody'] = $row->messageBody;
            $imUser['readStatus'] = $row->readStatus;
            $imUser['activityStatus'] = $row->activityStatus;
            $imUsers[] = $imUser;
        } echo json_encode(array($imUser));
    }

1 个答案:

答案 0 :(得分:4)

也许你想要: echo json_encode(array($ imUsers));

$ imUsers no $ imUser?