StoreCategory::model PHP Method

model() public static method

Returns the static model of the specified AR class.
public static model ( string $className = __CLASS__ ) : StoreCategory
$className string
return StoreCategory the static model class
    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }

Usage Example

 public function run($args)
 {
     mb_internal_encoding("UTF-8");
     mb_regex_encoding("UTF-8");
     Yii::app()->setImport(['application.modules.store.models.*']);
     $models = StoreCategory::model()->findAll();
     foreach ($models as $model) {
         $res = preg_replace('/\\s\\s+/', ' ', $model->name_ru);
         if ($res !== FALSE) {
             if (mb_strlen($res) !== mb_strlen($model->name_ru)) {
                 $model->name_ru = $res;
                 $model->update(['name_ru']);
                 print_r($model->id . ' ');
             }
         }
     }
     Yii::import('application.components.spreadsheetReader.SpreadsheetReader');
     $reader = new SpreadsheetReader(Yii::getPathOfAlias('application.components.spreadsheetReader.translates') . '/' . 'site_store_category.ods');
     foreach ($reader as $row) {
         if ($row[0] != 'id') {
             $res = Yii::app()->db->createCommand('
                 UPDATE `site_store_category` SET `name_en`= :row2, `name_zh_cn`= :row3, `name_zh_tw`= :row4 WHERE  `name_ru`= :row1;
             ')->execute([':row1' => $row[1], ':row2' => $row[2], ':row3' => $row[3], ':row4' => $row[4]]);
             print_r($res . ' ' . $row[2] . ' ');
         }
     }
 }
All Usage Examples Of StoreCategory::model