我在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);
}
}