Difference between #5 and #6 of
How to add a named scope to ActiveRecords with a behavior

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();

```


***
[...]
2 0
10 followers
Viewed: 35 875 times
Version: 1.1
Category: Tutorials
Tags:
Written by: Mike
Last updated by: yiqing95
Created on: Apr 30, 2009
Last updated: 12 years ago
Update Article

Revisions

View all history