Changes
Title
unchanged
How to add a named scope to ActiveRecords with a behavior
Category
unchanged
Tutorials
Yii version
unchanged
Tags
unchanged
Content
changed
[...]
* you can specify an alias here which can be the current ActiveRecord( normally is 't') or relation Ar 's alias(the relation name)
* @return CActiveRecord
*/
public function between($start,$end,$alias=null)
{
$alias = empty($alias)? $this->getOwner()->getTableAlias(false) : $alias;
if(empty($alias)){
$condition = $this->attrCreateAt.' BETWEEN :start AND :end';[...]
// ...
}
// with relation query ,the CreateAt is from Comment class. haven't test this funcitonality
$posts=Post::model()->between($start,$end,'comments')->with('comments')->findAll();
```
***[...]