Created
July 2, 2013 18:07
-
-
Save crisu83/5911637 to your computer and use it in GitHub Desktop.
Weight behavior
This file contains 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 WeightBehavior extends CActiveRecordBehavior | |
{ | |
/** | |
* @var string the name of the weight attribute. | |
*/ | |
public $weightAttribute = 'weight'; | |
/** | |
* Creates the criteria for ordering by weight. | |
* @return CDbCriteria the criteria. | |
*/ | |
public function createWeightCriteria() | |
{ | |
$criteria = new CDbCriteria(); | |
$criteria->order = 'weight ASC'; | |
return $criteria; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment