How to add a named scope to ActiveRecords with a behavior

Comparing #5 with #6

Content

[...]
* 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();

```


***
[...]