public static function setPlayerParamValue($playerId, $paramName, $value) { $wotParam = WotParam::getParamByName($paramName); $playerParam = self::model()->findByAttributes(array('player_id' => $playerId, 'param_id' => $wotParam->param_id)); if (empty($playerParam)) { $playerParam = new WotPlayerParam(); $playerParam->player_id = $playerId; $playerParam->param_id = $wotParam->param_id; } $playerParam->value = $value; $playerParam->save(false); }
public static function getParamByName($paramName) { if (empty(self::$_models)) { self::$_models = self::model()->findAll(array('index' => 'param_name')); } if (!isset(self::$_models[$paramName])) { $model = new self(); $model->param_name = $paramName; $model->save(false); self::$_models = self::model()->findAll(array('index' => 'param_name')); } return self::$_models[$paramName]; }