update remove by Query

This commit is contained in:
evgen-d
2014-08-12 10:33:20 +04:00
parent 1cb6b89d3d
commit 6790b11451
8 changed files with 40 additions and 65 deletions

View File

@@ -2,9 +2,9 @@
namespace devgroup\arangodb;
use triagens\ArangoDb\Cursor;
use triagens\ArangoDb\Document;
use Yii;
use triagens\ArangoDb\Document;
use triagens\ArangoDb\Statement;
use yii\base\Component;
use yii\base\InvalidParamException;
use yii\base\NotSupportedException;
@@ -12,9 +12,6 @@ use yii\db\QueryInterface;
use yii\helpers\ArrayHelper;
use yii\helpers\Json;
use triagens\ArangoDb\Statement;
use yii\helpers\VarDumper;
class Query extends Component implements QueryInterface
{
const PARAM_PREFIX = 'qp';
@@ -475,7 +472,7 @@ class Query extends Component implements QueryInterface
{
$doc = Json::encode($columns);
$aql = "INSERT $doc IN $collection";
$aql = "INSERT $doc IN {$this->quoteCollectionName($collection)}";
$options = ArrayHelper::merge(
$params,
@@ -528,10 +525,13 @@ class Query extends Component implements QueryInterface
Yii::endProfile($token, 'devgroup\arangodb\Query::update');
throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex);
}
return $cursor->getMetadata()['extra']['operations']['executed'];
$meta = $cursor->getMetadata();
return isset($meta['extra']['operations']['executed']) ?
$meta['extra']['operations']['executed'] :
true;
}
public function remove($collection, $condition, $params = [], $db = null)
public function remove($collection, $condition = [], $params = [], $db = null)
{
$this->from($collection);
$clauses = [
@@ -561,12 +561,17 @@ class Query extends Component implements QueryInterface
Yii::endProfile($token, 'devgroup\arangodb\Query::remove');
throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex);
}
return $cursor->getMetadata()['extra']['operations']['executed'];
$meta = $cursor->getMetadata();
return isset($meta['extra']['operations']['executed']) ?
$meta['extra']['operations']['executed'] :
true;
}
protected function buildUpdate($collection, $columns)
{
return 'UPDATE ' . $collection . ' WITH ' . Json::encode($columns) . ' IN ' . $collection;
return 'UPDATE ' . $collection . ' WITH '
. Json::encode($columns) . ' IN '
. $this->quoteCollectionName($collection);
}
protected function buildRemove($collection)