【发布时间】:2013-06-11 07:08:21
【问题描述】:
我在 codeigniter 中有一个模型,它使用 foreach 循环从数据库获取通知。我想使用 set_userdata 将值传递给会话,但不幸的是我无法将多个值传递给我的会话,请帮助。下面是我的模型
function get_user_notifications($userID){
$this->db->select()->from('messages')->where('receiverID',$userID);
$query = $this->db->get();
if($query->num_rows()>0)
{
foreach($query->result() as $rows)
{
//add all data to session
$notification=$rows->notification;
$messageID=$rows->messageID;
// $rows->messageID =>,
$this->session->set_userdata('mynotifications',$notification);
}
}
【问题讨论】:
-
你遇到了什么错误?
-
您必须在您实际要访问会话值的每个页面上启动会话。
标签: php codeigniter loops session foreach