yupe\components\behaviors\SortableBehavior::beforeSave PHP Method

beforeSave() public method

public beforeSave ( CModelEvent $event )
$event CModelEvent
    public function beforeSave($event)
    {
        if ($this->getOwner()->getIsNewRecord()) {
            $position = Yii::app()->getDb()->createCommand("select max(`{$this->attributeName}`) from {$this->getOwner()->tableName()}")->queryScalar();
            $this->getOwner()->{$this->attributeName} = (int) $position + 1;
        }
        return parent::beforeSave($event);
    }
SortableBehavior