本文整理汇总了PHP中app\models\Users::setWhere方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::setWhere方法的具体用法?PHP Users::setWhere怎么用?PHP Users::setWhere使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Users
的用法示例。
在下文中一共展示了Users::setWhere方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveAction
public function saveAction()
{
if (!$this->isXmlHttpRequest()) {
throw new \Exception('Неверный тип запроса!');
}
$usersModel = new Users();
$data = $this->request->getPost();
if (!isset($data['id']) || !isset($data['roles_id']) || !isset($data['user']) || !isset($data['password'])) {
throw new \Exception('Неверный тип запроса!');
}
if ($data['action'] == 'add' && (!isset($data['lastname']) || !isset($data['firstname']) || !isset($data['secondname']) || !isset($data['org_name']))) {
throw new \Exception('Неверный тип запроса!');
}
$data['id'] = (int) $data['id'];
if (!$data['id'] && $data['action'] != 'add') {
throw new \Exception('Неверный идентификатор пользователя!');
}
$data['roles_id'] = (int) $data['roles_id'];
if ($data['roles_id'] == 0) {
throw new \Exception('Не выбраны права пользователя!');
}
$data['user'] = trim($data['user']);
if ($data['user'] == '') {
throw new \Exception('Не заполнено обязательное поле Email!');
}
$data['password'] = trim($data['password']);
if ($data['password'] == '' && $data['action'] != 'add') {
unset($data['password']);
}
if (isset($data['password']) && mb_strlen($data['password']) < 6) {
throw new \Exception('Пароль должен быть больше 6 символов!');
}
if ($data['action'] == 'add') {
$data['lastname'] = trim($data['lastname']);
if ($data['lastname'] == '') {
throw new \Exception('Не заполнено обязательное поле Фамилия!');
}
$data['firstname'] = trim($data['firstname']);
if ($data['firstname'] == '') {
throw new \Exception('Не заполнено обязательное поле Имя!');
}
$data['secondname'] = trim($data['secondname']);
if ($data['secondname'] == '') {
throw new \Exception('Не заполнено обязательное поле Отчество!');
}
$data['org_name'] = trim($data['org_name']);
if ($data['org_name'] == '') {
throw new \Exception('Не заполнено обязательное поле Организация!');
}
}
unset($data['action']);
$data['id'] = $usersModel->save($data);
$usersModel->setWhere(array('id' => $data['id']));
$uData = $usersModel->select();
$this->view->data = $uData[0];
$rolesModel = new Roles();
$this->view->roles = $rolesModel->select();
}
示例2: getformAction
public function getformAction()
{
if (!$this->isXmlHttpRequest()) {
throw new \Exception('Неверный тип запроса!');
}
$project = false;
if (!is_null($this->request->getPost('id'))) {
$id = (int) $this->request->getPost('id');
$projectsModel = new Projects();
$project = $projectsModel->getProjectsDataForEdit($id);
$usersModel = new Users();
$usersModel->setWhere('`roles_id` IN(1,2)');
$this->view->initiators = $usersModel->select();
$usersModel->setWhere('`roles_id` IN(1,3)');
$this->view->executors = $usersModel->select();
$executorsModel = new Executors();
$this->view->selectedExecutors = $executorsModel->getExecutorsAsArrayByProject($id);
$statusModel = new Status();
$this->view->statuses = $statusModel->select();
}
$this->view->project = $project;
}
示例3: savestatusAction
public function savestatusAction()
{
if (!$this->isXmlHttpRequest()) {
throw new \Exception('Неверный тип запроса!');
}
$data = $this->request->getPost();
if (!isset($data['id']) || !isset($data['task_status_id'])) {
throw new \Exception('Неверный тип запроса!');
}
$data['id'] = (int) $data['id'];
$data['task_status_id'] = (int) $data['task_status_id'];
$tasksModel = new Tasks();
$tasksModel->save($data);
$timelineModel = new Timeline();
$timelineModel->endWork($data['id']);
$task = $tasksModel->getTasksDataById((int) $data['id']);
$to = array();
$usersModel = new Users();
$usersModel->setWhere(array('id' => 1));
$result1 = $usersModel->select();
$to[] = $result1[0]['user'];
$usersModel->setWhere(array('id' => (int) $task['executors_id']));
$result2 = $usersModel->select();
if ($result2 && $result2[0]['user'] != $result1[0]['user']) {
$to[] = $result2[0]['user'];
}
$usersModel->setWhere(array('id' => (int) $task['initiator']));
$result3 = $usersModel->select();
$to[] = $result3[0]['user'];
$subject = 'Изменение статуса задачи';
$message = 'По задаче "' . $task['name'];
$message .= '" сменился статус на ' . $task['ts_name'] . "\n";
$message .= 'По проекту: ' . ($task['p_name'] ? $task['p_name'] : 'Без проекта');
Mail::instance()->send($to, $subject, $message);
}