本文整理匯總了PHP中It::setMem方法的典型用法代碼示例。如果您正苦於以下問題:PHP It::setMem方法的具體用法?PHP It::setMem怎麽用?PHP It::setMem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類It
的用法示例。
在下文中一共展示了It::setMem方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionSensor
public function actionSensor()
{
$station = Station::model()->findByPk(isset($_REQUEST['station_id']) ? intval($_REQUEST['station_id']) : null);
$handler = SensorDBHandler::model()->with('features')->findByPk($_REQUEST['handler_id']);
if (is_null($station)) {
It::memStatus('station not found');
$this->redirect($this->createUrl('admin/stations'));
}
if (is_null($handler)) {
It::memStatus('handler not found');
$this->redirect($this->createUrl('admin/StationSave', array('station_id' => $station->station_id)));
}
$sensor = new StationSensor();
$sensor->station_id = $station->station_id;
$sensor->handler_id = $handler->handler_id;
$sensor->display_name = $handler->handler_default_display_name;
$sql = "SELECT UPPER(`sensor_id_code`) FROM `" . StationSensor::model()->tableName() . "` WHERE `station_id` = ? AND `sensor_id_code` <> ?";
$used_code_id = Yii::app()->db->createCommand($sql)->queryColumn(array($station->station_id, $sensor->sensor_id_code ? $sensor->sensor_id_code : ''));
for ($i = 1; $i <= 9; $i++) {
$code = $handler->default_prefix . $i;
if (!$used_code_id || !in_array($code, $used_code_id)) {
$sensor->sensor_id_code = $code;
break;
}
}
if (!$sensor->sensor_id_code) {
It::memStatus('sensor ' . $handler->display_name . ' is full');
$this->redirect($this->createUrl('admin/sensors', array('station_id' => $station->station_id)));
}
$sensorHandler = SensorHandler::create($handler->handler_id_code);
$sensorFeatures = array();
$ft_1 = $sensorHandler->getFeatures();
$ft_2 = $sensorHandler->getExtraFeatures();
if ($ft_2) {
foreach ($ft_2 as $key => $value) {
$ft_2[$key]['is_extra'] = 1;
}
}
$handler_sensor_features = array_merge($ft_1, $ft_2);
if ($handler_sensor_features) {
foreach ($handler_sensor_features as $value) {
$sf = new StationSensorFeature();
$default = $handler->features[$value['feature_code']];
$metric = RefbookMeasurementType::model()->with('metricMain')->findByAttributes(array('code' => $value['measurement_type_code']));
$sf->feature_constant_value = isset($value['default']) ? $value['default'] : null;
if ($default) {
$sf->feature_constant_value = $default->feature_constant_value;
$sf->metric_id = $default->metric_id;
$sf->filter_max = $default->filter_max;
$sf->filter_min = $default->filter_min;
$sf->filter_diff = $default->filter_diff;
}
$sf->metric_id = $metric->metricMain->metric_id;
$sf->feature_code = $value['feature_code'];
$sf->feature_display_name = $value['feature_name'];
$sf->is_constant = isset($value['is_extra']) ? 1 : 0;
$sf->comment = isset($value['comment']) ? $value['comment'] : null;
$sf->measurement_type_code = $value['measurement_type_code'];
$sf->is_cumulative = $value['is_cumulative'];
$sf->is_main = $value['is_main'];
$sf->has_filter_min = $value['has_filter_min'];
$sf->has_filter_max = $value['has_filter_max'];
$sf->has_filter_diff = $value['has_filter_diff'];
$sensorFeatures[] = $sf;
}
}
$validated = $sensor->validate();
if ($validated and $sensorFeatures) {
foreach ($sensorFeatures as $feature) {
$feature->sensor_id = 1;
$validated = $validated & $feature->validate();
}
if ($validated) {
$sensor->save(false);
if ($sensorFeatures) {
foreach ($sensorFeatures as $feature) {
$feature->sensor_id = $sensor->station_sensor_id;
$feature->save(false);
}
}
It::memStatus('sensor created');
It::setMem('sensor_id', $sensor->station_sensor_id);
$this->redirect($this->createUrl('admin/sensors', array('station_id' => $station->station_id)));
}
}
It::memStatus('sensor save fail');
$this->redirect($this->createUrl('admin/sensors', array('station_id' => $station->station_id)));
}