Make sure query cloning works as expected.

This commit is contained in:
Qiang Xue
2013-08-29 17:19:22 -04:00
parent 30d6229943
commit cb60fa5ddd
2 changed files with 10 additions and 1 deletions

View File

@@ -9,7 +9,6 @@ namespace yii\data;
use Yii; use Yii;
use yii\base\InvalidConfigException; use yii\base\InvalidConfigException;
use yii\base\InvalidParamException;
use yii\base\Model; use yii\base\Model;
use yii\db\Query; use yii\db\Query;
use yii\db\ActiveQuery; use yii\db\ActiveQuery;

View File

@@ -50,6 +50,16 @@ class ActiveRelation extends ActiveQuery
*/ */
public $via; public $via;
/**
* Clones internal objects.
*/
public function __clone()
{
if (is_object($this->via)) {
// make a clone of "via" object so that the same query object can be reused multiple times
$this->via = clone $this->via;
}
}
/** /**
* Specifies the relation associated with the pivot table. * Specifies the relation associated with the pivot table.