added condition to batchInsert against empty arrays

This commit is contained in:
Anton Grebnev
2012-01-19 19:16:31 +04:00
parent 99a528fac3
commit 0140c3f4ad
3 changed files with 10 additions and 1 deletions

View File

@ -125,11 +125,14 @@ class InsertMongoCommand extends MongoDbCommand
protected function concreteExecute()
{
$result = null;
if (!$this->multiple) {
$result = $this->collection->insert($this->data, array('safe' => $this->safe));
$this->insertId = $this->data['_id'];
} else {
$result = $this->collection->batchInsert($this->data, array('safe' => $this->safe));
if (count($this->data)) {
$result = $this->collection->batchInsert($this->data, array('safe' => $this->safe));
}
}
return $result;
}