Ejemplo n.º 1
0
 /**
  * @param string $scenario
  * @param int $id Model primary key
  */
 function __construct($scenario = self::SC_INSERT, $id = null)
 {
     $this->initAttributes();
     $this->_scenario = $scenario;
     $this->_db = App::db();
     /** If set id search by primary key else create default attributes  */
     if (isset($id)) {
         $this->findByPk($id);
     }
 }
Ejemplo n.º 2
0
 /** Save files count */
 public function saveFilesCount()
 {
     $this->saveAttr(array('files_count' => App::db()->runSql('select count(*) from tbl_file where userid = :userid and statusid =  ' . FileModel::SC_STATUS_ACTIVE, array(':userid' => $this->userid))->fetchColumn()));
 }