jenssegers/MongoDB 这个包 insert 时候不支持输入参数?
刚才用到这个拓展包来插入一些数据进mongo,可是发现源码里并不支持携带参数
Jenssegers\Mongodb\Query\Builder;
public function insert(array $values)
{
// Since every insert gets treated like a batch insert, we will have to detect
// if the user is inserting a single document or an array of documents.\ $batch = true;
foreach ($values as $value) {
// As soon as we find a value that is not an array we assume the user is
// inserting a single document.\ if (!is_array($value)) {
$batch = false;
break;
}
}
if (!$batch) {
$values = [$values];
}
// Batch insert
$result = $this->collection->insertMany($values);
return (1 == (int) $result->isAcknowledged());
}
是我不会用,还是真的不能有参数?
关于 LearnKu
你这个参数指的是什么
@liyu001989 ,在官网看到mongo4.0的文档,insert可以传入参数
ordered,表示是否需要顺序插入,这个参数找不到在拓展包里哪里可以接收刚才忘发链接了,不好意思
https://docs.mongodb.com/manual/reference/method/db.collection.insertMany/#db.collection.insertMany可能得去 issue 里面看看,或者提 issue 问问作者
@liyu001989 刚才搜了搜,好像没人用到这个参数,我已经用php的mongoDB拓展写好代码了~以后给作者提个问,看看能不能加上insert参数