嗨我新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(); } –