Skip to content

Instantly share code, notes, and snippets.

@crisu83
Created July 2, 2013 18:07
Show Gist options
  • Save crisu83/5911637 to your computer and use it in GitHub Desktop.
Save crisu83/5911637 to your computer and use it in GitHub Desktop.
Weight behavior
<?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