Исправление метода удаления документа: remove()
This commit is contained in:
parent
bb4fa52274
commit
1592238e5f
|
@ -388,7 +388,7 @@ abstract class ActiveRecord extends BaseActiveRecord
|
||||||
if ($lock !== null) {
|
if ($lock !== null) {
|
||||||
$condition[$lock] = $this->$lock;
|
$condition[$lock] = $this->$lock;
|
||||||
}
|
}
|
||||||
$result = (new Query())->options($options)->remove(static::collectionName(), $condition);
|
$result = (new Query())->options($options)->collection(static::collectionName())->remove($condition);
|
||||||
if ($lock !== null && !$result) {
|
if ($lock !== null && !$result) {
|
||||||
throw new StaleObjectException('The object being deleted is outdated.');
|
throw new StaleObjectException('The object being deleted is outdated.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -886,8 +886,6 @@ class Query extends Component implements QueryInterface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param null $db
|
* @param null $db
|
||||||
* @return array|bool
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
public function one($db = null)
|
public function one($db = null)
|
||||||
{
|
{
|
||||||
|
@ -1002,14 +1000,13 @@ class Query extends Component implements QueryInterface
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function remove($collection, $condition = [], $params = [], $db = null)
|
public function remove($condition = [], $params = [], $db = null)
|
||||||
{
|
{
|
||||||
$this->collection = $collection;
|
|
||||||
$clauses = [
|
$clauses = [
|
||||||
$this->genFor($collection),
|
static::genFor($this->for ?? $this->collection),
|
||||||
$this->genIn($collection),
|
static::genIn($this->in ?? $this->collection, $this->traversals),
|
||||||
$this->genWhere($condition, $params),
|
$this->genWhere($condition, $params),
|
||||||
$this->genRemove($collection),
|
$this->genRemove($this->in ?? $this->collection),
|
||||||
$this->genOptions(),
|
$this->genOptions(),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -1213,6 +1210,7 @@ class Query extends Component implements QueryInterface
|
||||||
$statement->setBatchSize(1);
|
$statement->setBatchSize(1);
|
||||||
|
|
||||||
$token = $this->getRawAql($statement);
|
$token = $this->getRawAql($statement);
|
||||||
|
|
||||||
Yii::info($token, 'mirzaev\yii2\arangodb\Query::query');
|
Yii::info($token, 'mirzaev\yii2\arangodb\Query::query');
|
||||||
try {
|
try {
|
||||||
Yii::beginProfile($token, 'mirzaev\yii2\arangodb\Query::query');
|
Yii::beginProfile($token, 'mirzaev\yii2\arangodb\Query::query');
|
||||||
|
@ -1222,6 +1220,7 @@ class Query extends Component implements QueryInterface
|
||||||
Yii::endProfile($token, 'mirzaev\yii2\arangodb\Query::query');
|
Yii::endProfile($token, 'mirzaev\yii2\arangodb\Query::query');
|
||||||
throw new Exception($ex->getMessage(), (int) $ex->getCode(), $ex);
|
throw new Exception($ex->getMessage(), (int) $ex->getCode(), $ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $cursor->getFullCount();
|
return $cursor->getFullCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1546,7 +1545,11 @@ class Query extends Component implements QueryInterface
|
||||||
*/
|
*/
|
||||||
public function limit($limit)
|
public function limit($limit)
|
||||||
{
|
{
|
||||||
|
// Если $limit === 0 то $limit = null
|
||||||
|
$limit === 0 and $limit = null;
|
||||||
|
|
||||||
$this->limit = $limit;
|
$this->limit = $limit;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,18 +5,28 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* @var $className string the new migration class name */
|
/* @var $className string the new migration class name */
|
||||||
echo "<?php\n";
|
|
||||||
?>
|
|
||||||
|
|
||||||
class <?= $className ?> extends \mirzaev\yii2\arangodb\Migration
|
echo <<<HTML
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use mirzaev\yii2\arangodb\Migration;
|
||||||
|
|
||||||
|
class $className extends Migration
|
||||||
{
|
{
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->createCollection('<?= $className ?>',[]);
|
/**
|
||||||
|
* @param string Название коллекции
|
||||||
|
* @param array Тип коллекции (2 - документ, 3 - ребро)
|
||||||
|
*/
|
||||||
|
\$this->createCollection('$className', ['type' => 2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
$this->dropCollection('<?= $className ?>');
|
\$this->dropCollection('$className');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
HTML;
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
Loading…
Reference in New Issue