Browse Source

Fixes issue #134

tags/2.0.0-beta
Qiang Xue 12 years ago
parent
commit
034d88e5e4
  1. 4
      docs/api/db/ActiveRecord.md
  2. 3
      framework/db/ActiveQuery.php
  3. 2
      tests/unit/data/ar/Customer.php

4
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));
}

3
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);
}

2
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');
}
}

Loading…
Cancel
Save