update remove fix

This commit is contained in:
evgen-d 2014-08-11 16:32:03 +04:00
parent 9f1dea1740
commit 98a5693450

View File

@ -2,6 +2,7 @@
namespace devgroup\arangodb;
use triagens\ArangoDb\Document;
use yii\base\Component;
use yii\db\MigrationInterface;
use yii\di\Instance;
@ -51,7 +52,10 @@ abstract class Migration extends Component implements MigrationInterface
{
echo " > update $collection ...";
$time = microtime(true);
(new Query())->update($collection, $columns, $condition, $params)->execute();
$docs = (new Query())->select($collection)->from($collection)->where($condition, $params)->all();
foreach ($docs as $doc) {
$this->db->getDocumentHandler()->updateById($collection, $doc['_key'], Document::createFromArray($columns));
}
echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n";
}
@ -59,7 +63,10 @@ abstract class Migration extends Component implements MigrationInterface
{
echo " > delete from $collection ...";
$time = microtime(true);
(new Query())->remove($collection, $condition, $params)->execute();
$docs = (new Query())->select($collection)->from($collection)->where($condition, $params)->all();
foreach ($docs as $doc) {
$this->db->getDocumentHandler()->removeById($collection, $doc['_key']);
}
echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n";
}