added butchInsert to mongo model

This commit is contained in:
Anton Grebnev
2012-01-18 23:30:34 +04:00
parent d1723cb87b
commit 99a528fac3
6 changed files with 118 additions and 18 deletions

View File

@ -121,10 +121,16 @@ class InsertMongoCommand extends MongoDbCommand
protected $insertId = false;
protected $multiple = false;
protected function concreteExecute()
{
$result = $this->collection->insert($this->data, array('safe' => $this->safe));
$this->insertId = $this->data['_id'];
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));
}
return $result;
}
@ -150,6 +156,8 @@ class InsertMongoCommand extends MongoDbCommand
var_dump($this->data);
$data = ob_get_clean();
$result .= 'Data: ' . $data . PHP_EOL;
$mult = $this->multiple ? 'TRUE' : 'FALSE';
$result .= 'Bulk insert: ' . $mult . PHP_EOL;
$safe = $this->safe ? 'TRUE' : 'FALSE';
$result .= 'Safe operation: ' . $safe . PHP_EOL;
return $result;
@ -174,13 +182,13 @@ class UpdateMongoCommand extends MongoDbCommand
protected function concreteExecute()
{
return $this->collection->update($this->condition, $this->data,
array('multiple' => $this->multiple, 'upsert' => $this->upsert, 'safe' => $this->safe));
array('multiple' => $this->multiple, 'upsert' => $this->upsert, 'safe' => $this->safe));
}
protected function checkParams()
{
if (isset($this->collection) && isset($this->condition) && isset($this->data) &&
isset($this->upsert) && isset($this->safe)
isset($this->upsert) && isset($this->safe)
) {
return true;
} else {