added butchInsert to mongo model
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user