Ejemplo n.º 1
0
 public static function getConfigs()
 {
     //$configs = Yii::app()->db->createCommand('SELECT * FROM configs WHERE status = 1')->queryAll();
     $configs = Configs::model()->findAll('status = 1');
     $arr = array();
     if ($configs != null) {
         foreach ($configs as $r) {
             if ($r->alias == 'nuumber-mobile' || $r->alias == 'number-tablets' || $r->alias == 'number-laptop') {
                 $configMobile = explode("|", $r->value);
                 if (count($configMobile) == 1) {
                     $configMobile[1] = 0;
                 }
                 if (time() - strtotime($r->updated) > 86400) {
                     $configMobile[0] = $configMobile[0] + $configMobile[1];
                     $r->value = $configMobile[0] . " | " . $configMobile[1];
                     $r->save();
                 }
                 $arr[$r->alias] = $configMobile[0];
             } else {
                 $arr[$r->alias] = $r->value;
             }
         }
     }
     return $arr;
 }
Ejemplo n.º 2
0
 /**
  * @param $id
  * @return bool
  */
 public function removeConfig($id)
 {
     return Configs::model()->deleteByPk($id);
 }