本文整理汇总了PHP中UserModule::model方法的典型用法代码示例。如果您正苦于以下问题:PHP UserModule::model方法的具体用法?PHP UserModule::model怎么用?PHP UserModule::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserModule
的用法示例。
在下文中一共展示了UserModule::model方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionSave
public function actionSave()
{
$id = $_POST['id'];
$ha = UserModule::model()->deleteAllByAttributes(array("user_level_id" => $id));
$q = $_POST['q'];
$arr = explode(";;", $q);
$num = 1;
foreach ($arr as $elem) {
$ha = new UserModule();
$ha->user_level_id = $id;
$ha->module_id = $elem;
$ha->save();
$num++;
}
}
示例2: isAda
function isAda($level, $module_id)
{
$h = UserModule::model()->findByAttributes(array("user_level_id" => $level, "module_id" => $module_id));
if ($h) {
return TRUE;
} else {
return FALSE;
}
}
示例3: actionView
public function actionView()
{
// Check if id was submitted via GET
if (!isset($_GET['id']) && !isset($_GET['username'])) {
$this->_sendResponse(500, 'Error: Parameter <b>id</b> or <b>username</b> is missing');
}
switch ($_GET['model']) {
// Find respective model
case 'detailuser':
$model['user'] = User::model()->findByPk($_GET['id']);
$model['dealer'] = $model['user']->dealer;
$model['modules'] = $model['user']->modules;
$rooms = $model['user']->rooms;
$i = 0;
foreach ($rooms as $room) {
$roominfo[$i] = $room->attributes;
$roominfo[$i]['lights'] = $room->lights;
$j = 0;
foreach ($roominfo[$i]['lights'] as $light) {
$roominfo[$i]['lights'][$j] = $light->attributes;
$roominfo[$i]['lights'][$j]['module'] = $light->module;
$j++;
}
$roominfo[$i]['motors'] = $room->motors;
$j = 0;
foreach ($roominfo[$i]['motors'] as $motor) {
$roominfo[$i]['motors'][$j] = $motor->attributes;
$roominfo[$i]['motors'][$j]['module'] = $motor->module;
$j++;
}
$roominfo[$i]['airConditions'] = $room->airConditions;
$j = 0;
foreach ($roominfo[$i]['airConditions'] as $airCondition) {
$roominfo[$i]['airConditions'][$j] = $airCondition->attributes;
$roominfo[$i]['airConditions'][$j]['module'] = $airCondition->module;
$j++;
}
$roominfo[$i]['roomScenes'] = $room->roomScenes;
$j = 0;
foreach ($roominfo[$i]['roomScenes'] as $roomScene) {
$roominfo[$i]['roomScenes'][$j] = $roomScene->attributes;
$roominfo[$i]['roomScenes'][$j]['roomSceneCommands'] = $roomScene->roomSceneCommands;
$j++;
}
$i++;
}
$model['rooms'] = $roominfo;
$model['modules'] = $model['user']->modules;
$model['houseScenes'] = $model['user']->houseScenes;
$i = 0;
foreach ($model['houseScenes'] as $houseScene) {
$model['houseScenes'][$i] = $houseScene->attributes;
$model['houseScenes'][$i]['houseSceneCommands'] = $houseScene->houseSceneCommands;
$i++;
}
$model['nuvo6s'] = $model['user']->nuvo6s;
break;
case 'user':
// $user = User::model()->findByPk($_GET['id']);
$user = User::model()->find('username=:username', array(':username' => $_GET['username']));
if ($_GET['password'] != $user->password) {
$this->_sendResponse(404, 'wrong password');
}
$model['user'] = $user;
$model['dealer'] = $user->dealer;
$model['modules'] = UserModule::model()->findAll('user_id=:user_id', array(':user_id' => $user->id));
$model['rooms'] = UserRoom::model()->findAll('user_id=:user_id', array(':user_id' => $user->id));
$model['lights'] = UserLight::model()->findAll('user_id=:user_id', array(':user_id' => $user->id));
$model['macros'] = UserMacro::model()->findAll('user_id=:user_id', array(':user_id' => $user->id));
$model['motors'] = UserMotor::model()->findAll('user_id=:user_id', array(':user_id' => $user->id));
$model['g4motors'] = UserG4Motor::model()->findAll('user_id=:user_id', array(':user_id' => $user->id));
$model['acs'] = UserAirCondition::model()->findAll('user_id=:user_id', array(':user_id' => $user->id));
$model['nuvo6s'] = UserNuvo6::model()->findAll('user_id=:user_id', array(':user_id' => $user->id));
$model['security'] = UserSecurityControl::model()->findAll('user_id=:user_id', array(':user_id' => $user->id));
$model['housescenes'] = UserHouseScene::model()->findAll('user_id=:user_id', array(':user_id' => $user->id));
$model['roomscenes'] = UserRoomScene::model()->findAll('user_id=:user_id', array(':user_id' => $user->id));
$model['messages'] = UserInbox::model()->findAll('user_id=:user_id AND status<:status', array(':user_id' => $user->id, ':status' => 2));
break;
default:
$this->_sendResponse(501, sprintf('Mode <b>view</b> is not implemented for model <b>%s</b>', $_GET['model']));
Yii::app()->end();
}
// Did we find the requested model? If not, raise an error
if (is_null($model) || is_null($user)) {
$this->_sendResponse(404, 'No Item found with id ' . $_GET['id']);
} else {
$this->_sendResponse(200, CJSON::encode($model));
}
}