Last active
September 28, 2015 10:38
-
-
Save jamband/1426071 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Hoge extends CActiveRecord | |
{ | |
... | |
/** | |
* @see CActiveRecord::scopes() | |
*/ | |
public function scopes() | |
{ | |
return array( | |
'a' => array( | |
'condition' => 't.user_id = :user_id', | |
'params' => array(':user_id' => Yii::app()->user->id), | |
), | |
'b' => array( | |
'select' => 't.fuga, t.piyo', | |
'order' => 't.id DESC', | |
), | |
); | |
} | |
/** | |
* すべて取得 | |
* @return array | |
*/ | |
public function getAll() | |
{ | |
$c = new CDbCriteria(); | |
$count = $this->a()->count($c); | |
$pages = new CPagination($count); | |
$pages->pageSize = 30; | |
$pages->applyLimit($c); | |
return array( | |
$pages, | |
$this->a()->b()->findAll($c), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment