Last active
December 29, 2015 17:12
-
-
Save jamband/1471371 to your computer and use it in GitHub Desktop.
Yii Framework: How to specify a column alias.
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 Forum extends ActiveRecord | |
{ | |
public $max_number; | |
public $max_create_time; | |
... | |
public function getLatestAll() | |
{ | |
$c = new CDbCriteria(); | |
$c->with = array('topic'); | |
$c->select = 'MAX(t.number) AS max_number, MAX(t.create_time) AS max_create_time'; | |
$c->group = 't.topic_id'; | |
$c->order = 'mac_create_time DESC'; | |
return $this->findAll($c); | |
} | |
... |
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 foreach ($models as $model): ?> | |
<?php echo CHtml::encode($model->max_createtime); ?> | |
<?php echo CHtml::encode($model->max_number); ?> | |
... | |
<?php endforeach; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you. ^^