When I call the static method in Yii Model it fails. Below is the code. Am I done anything wrong in the coding.
Is the calss is imported before view?
What am i missing here?
class ListModel extends CActiveRecord {
const STATUS_PENDING = 0;
public static function model($className=__CLASS__) {
return parent::model($className);
}
public function tableName() {
return 'list_model';
}
public static function getCountPending(){
$sql = "SELECT COUNT('list_id') FROM list_model WHERE list_status=".self::STATUS_PENDING;
return (int) Yii::app()->db
->createCommand($sql)
->queryScalar();
}
//Main
return array(
'import'=>array(
'application.modules.list.models.*',
),
)
//View
$pending = ListModel::getCountPending();