From 32f7ae904614e01b7a43101a2cd2e09d98b9baca Mon Sep 17 00:00:00 2001
From: evgen-d <flynn068@gmail.com>
Date: Tue, 5 Aug 2014 10:12:32 +0400
Subject: [PATCH] add $db

---
 ActiveQuery.php |  2 +-
 Query.php       | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/ActiveQuery.php b/ActiveQuery.php
index 75fb972..2e8ace7 100644
--- a/ActiveQuery.php
+++ b/ActiveQuery.php
@@ -117,7 +117,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
 
     public function all($db = null)
     {
-        $statement = $this->createCommand();
+        $statement = $this->createCommand($db);
         $token = $this->getRawAql($statement);
         Yii::info($token, 'devgroup\arangodb\Query::query');
         try {
diff --git a/Query.php b/Query.php
index ceb8036..ed62e36 100644
--- a/Query.php
+++ b/Query.php
@@ -65,7 +65,7 @@ class Query extends Component implements QueryInterface
         return $db->getStatement($options);
     }
 
-    public function createCommand($options = [])
+    public function createCommand($db = null, $options = [])
     {
         list ($aql, $params) = $this->buildQuery($this);
 
@@ -77,7 +77,7 @@ class Query extends Component implements QueryInterface
             ]
         );
 
-        return $this->getStatement($options);
+        return $this->getStatement($options, $db);
     }
 
     public function update($collection, $columns, $condition, $params)
@@ -489,7 +489,7 @@ class Query extends Component implements QueryInterface
 
     public function all($db = null)
     {
-        $statement = $this->createCommand();
+        $statement = $this->createCommand($db);
         $token = $this->getRawAql($statement);
         Yii::info($token, 'devgroup\arangodb\Query::query');
         try {
@@ -506,7 +506,7 @@ class Query extends Component implements QueryInterface
     public function one($db = null)
     {
         $this->limit(1);
-        $statement = $this->createCommand();
+        $statement = $this->createCommand($db);
         $token = $this->getRawAql($statement);
         Yii::info($token, 'devgroup\arangodb\Query::query');
         try {
@@ -540,7 +540,7 @@ class Query extends Component implements QueryInterface
 
     public function count($q = '*', $db = null)
     {
-        $statement = $this->createCommand();
+        $statement = $this->createCommand($db);
         $statement->setCount(true);
         $token = $this->getRawAql($statement);
         Yii::info($token, 'devgroup\arangodb\Query::query');