我有一个数组
Array([全名] => Rahul [用户名] => rony [密码] => 12345 [repassword] => 12345 [名称] =>经理[部门] =>技术[mob_no] => 9856565656 [用户类型] => comadmin [权限] =>完成[提交] =>提交
现在,我想通过codeignitor将此数据插入mongodb集合。请提出合适的代码。.预先感谢..
我的模型是这样的: AppconfigModel类扩展CI_Model {
protected $manager = null;
public function __construct()
{
parent::__construct();
$this->manager = new MongoDB\Driver\Manager('mongodb://localhost:27017');
}
public function insert_masteradmin($array)
{
$bulk = new MongoDB\Driver\BulkWrite($array);
$manager = new MongoDB\Driver\Manager('mongodb://localhost:27017');
$writeConcern = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, 1000);
try {
$result = $manager->executeBulkWrite('justrack_db.master_admin', $bulk);
}
catch (MongoDB\Driver\Exception\BulkWriteException $e)
{
$result = $e->getWriteResult();
}
}
}
现在,请建议我,如何将数组数据存储到集合中