From 034d88e5e480d2a681f336acc3b0bdd7c758cc42 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Mon, 6 May 2013 08:04:35 -0400 Subject: [PATCH] Fixes issue #134 --- docs/api/db/ActiveRecord.md | 4 ++-- framework/db/ActiveQuery.php | 3 ++- tests/unit/data/ar/Customer.php | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/api/db/ActiveRecord.md b/docs/api/db/ActiveRecord.md index 822c548..4e82793 100644 --- a/docs/api/db/ActiveRecord.md +++ b/docs/api/db/ActiveRecord.md @@ -412,7 +412,7 @@ class Customer extends \yii\db\ActiveRecord /** * @param ActiveQuery $query */ - public function active($query) + public static function active($query) { $query->andWhere('status = 1'); } @@ -435,7 +435,7 @@ class Customer extends \yii\db\ActiveRecord * @param ActiveQuery $query * @param integer $age */ - public function olderThan($query, $age = 30) + public static function olderThan($query, $age = 30) { $query->andWhere('age > :age', array(':age' => $age)); } diff --git a/framework/db/ActiveQuery.php b/framework/db/ActiveQuery.php index 43c3059..3999600 100644 --- a/framework/db/ActiveQuery.php +++ b/framework/db/ActiveQuery.php @@ -88,7 +88,8 @@ class ActiveQuery extends Query { if (method_exists($this->modelClass, $name)) { array_unshift($params, $this); - return call_user_func_array(array($this->modelClass, $name), $params); + call_user_func_array(array($this->modelClass, $name), $params); + return $this; } else { return parent::__call($name, $params); } diff --git a/tests/unit/data/ar/Customer.php b/tests/unit/data/ar/Customer.php index 9b3eab6..b26b51b 100644 --- a/tests/unit/data/ar/Customer.php +++ b/tests/unit/data/ar/Customer.php @@ -22,6 +22,6 @@ class Customer extends ActiveRecord public static function active($query) { - return $query->andWhere('status=1'); + $query->andWhere('status=1'); } }