如何将数组从codeigniter Helper传递给contorller

时间:2016-02-28 09:02:04

标签: php arrays codeigniter

我正在开发一个通知系统,我需要使用帮助程序来计算和列出所有警报。 当我从帮助者尝试print_r时,我能够看到数组中的所有项目,而当我从控制器中执行相同的操作时,我只能看到一个项目。 例如:..

通知帮助

  function notification_list($ci)
  {
    $userID = $ci->session->userdata('user_id');
    $getNotifications =$ci->model_notifications->get_all(array("UserID"=>$userID), 'usernotifications');

    foreach ($getNotifications as $notifications)
    {           
      $ListNotifications =$ci->model_notifications->get_all(array("ID"=>$notifications->NotificationID), 'notifications');
      print_r($ListNotifications);
    }
  }

输出

Array ( [0] => stdClass Object ( [ID] => 1 [Title] => Demo Notification [Message] => Lorem ipsum dolor sit amet, consectetur adipiscing elit. In volutpat dui quis neque fringilla semper. Praesent vel sollicitudin leo. Nulla facilisi. Curabitur quis sapien a metus facilisis malesuada. Nulla vitae quam vel turpis viverra pharetra fringilla ac urna. Vivamus hendrerit a quam ac hendrerit. [Type] => 2 [ActionID] => 3 [StatusID] => 1 ) ) Array ( [0] => stdClass Object ( [ID] => 2 [Title] => Demo Alert [Message] => Lorem ipsum dolor sit amet, consectetur adipiscing elit. In volutpat dui quis neque fringilla semper. Praesent vel sollicitudin leo. Nulla facilisi. Curabitur quis sapien a metus facilisis malesuada. [Type] => 1 [ActionID] => 3 [StatusID] => 1 ) )

但是当我从我的控制器返回$ListNotificationsprint_r(notification_list($ci))时,我只能看到一个结果。像这样的东西:

Array ( [0] => stdClass Object ( [ID] => 1 [Title] => Demo Notification [Message] => Lorem ipsum dolor sit amet, consectetur adipiscing elit. In volutpat dui quis neque fringilla semper. Praesent vel sollicitudin leo. Nulla facilisi. Curabitur quis sapien a metus facilisis malesuada. Nulla vitae quam vel turpis viverra pharetra fringilla ac urna. Vivamus hendrerit a quam ac hendrerit. [Type] => 2 [ActionID] => 3 [StatusID] => 1 ) ) 
你觉得我在这里做错了什么?有没有办法可以将数组从我的帮助器返回到控制器?

由于 最大

0 个答案:

没有答案