/** * @return WotMap the static model class */ public static function getByName($mapName) { $model = self::model()->findByAttributes(array('map_name' => $mapName)); if (empty($model)) { $model = new WotMap(); $model->map_name = $mapName; $model->save(false); } return $model; }