嗨我新mongodb和codeigniter我試圖做簡單的增刪改查操作 mongodb和php codeigniter我想通過我的數組從控制器查看,但它不能完成它給出了一個錯誤時遇到 甲PHP錯誤從控制器傳遞數組在codeigniter中查看
嚴重性:注意
消息:未定義變量:USER_LIST
文件名:視圖/ show_user.php
行號:15
這裏是我的控制器
class user extends CI_Controller
{
public function __construct()
{
parent::__construct();
//loading the mongodb library
$this->load->model('mongo_model');
}
//index where the controller starts
public function index()
{
$collection = $this->mongo_model->selectCollectiondb();
$collection= iterator_to_array($collection);
foreach ($collection as $users)
{
$data['_id']=$users['_id'];
$data['firstname']=$users['firstname'];
$data['lastname']=$users['lastname'];
$data['email']=$users['email'];
$data['password']=$users['password'];
}
print_r($data);
$this->load->view('show_user',$data);
}
}
代碼視圖代碼是
<?php
print_r($user_list);
exit();
<?php }?>
這裏是我的模型代碼 公共職能selectCollectiondb(){ $ 查詢= $這個 - > mongo_db-> DB-> selectCollection( 'myfirstCollection'); return $ result = $ query-> find(); } –