当前位置: 首页>>代码示例>>PHP>>正文


PHP Manager::findFirst方法代码示例

本文整理汇总了PHP中Manager::findFirst方法的典型用法代码示例。如果您正苦于以下问题:PHP Manager::findFirst方法的具体用法?PHP Manager::findFirst怎么用?PHP Manager::findFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Manager的用法示例。


在下文中一共展示了Manager::findFirst方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateleaderAction

 public function updateleaderAction()
 {
     $this->view->disable();
     $manager = $this->session->get('Manager');
     if (empty($manager)) {
         $this->dataReturn(array('error' => '获取用户信息失败,请重新登陆'));
         return;
     }
     $project_id = $manager->project_id;
     $oper = $this->request->getPost('oper', 'string');
     if ($oper == 'add') {
         $data = array();
         $data[] = $this->request->getPost('name', 'string');
         try {
             PmDB::insertLeader($data, $project_id);
         } catch (Exception $e) {
             $this->dataReturn(array('error' => '记录插入失败'));
             return;
         }
         $this->dataReturn(array('flag' => true));
         return;
     } else {
         if ($oper == 'edit') {
             //edit
             $id = $this->request->getPost('id', 'int');
             $manager = Manager::findFirst($id);
             //$manager ->username       = $this->request->getPost('username', 'string');
             $manager->name = $this->request->getPost('name', 'string');
             $manager->password = $this->request->getPost('password', 'string');
             try {
                 PmDB::updateManager($manager);
             } catch (Exception $e) {
                 $this->dataReturn(array('error' => '记录更新失败'));
                 return;
             }
             $this->dataReturn(array('flag' => true));
             return;
         } else {
             if ($oper == 'del') {
                 #删除可选择多项
                 $ids = $this->request->getPost('id', 'string');
                 #删除未加限制
                 $id_array = explode(',', $ids);
                 $managers = $this->modelsManager->createBuilder()->from('Manager')->where('project_id = ' . $project_id . " AND role = 'L'")->inWhere('id', $id_array)->getQuery()->execute();
                 try {
                     PmDB::deleteManagers($managers);
                 } catch (Exception $e) {
                     $this->dataReturn(array('error' => '记录删除失败'));
                     return;
                 }
                 $this->dataReturn(array('flag' => true));
                 return;
             } else {
                 //add ...
             }
         }
     }
 }
开发者ID:sunxfancy,项目名称:Questionnaire,代码行数:58,代码来源:PmController.php

示例2: updateleaderAction

 public function updateleaderAction()
 {
     $oper = $this->request->getPost('oper', 'string');
     if ($oper == 'edit') {
         $id = $this->request->getPost('id', 'int');
         $manager = Manager::findFirst($id);
         $manager->name = $this->request->getPost('name', 'string');
         $manager->password = $this->request->getPost('password', 'string');
         $manager->project_id = $this->request->getPost('project_id', 'int');
         if (!$manager->save()) {
             foreach ($manager->getMessages() as $message) {
                 echo $message;
             }
         }
     }
     if ($oper == 'del') {
         $id = $this->request->getPost('id', 'int');
         $manager = Manager::findFirst($id);
         if (!$manager->delete()) {
             foreach ($manager->getMessages() as $message) {
                 echo $message;
             }
         }
     }
 }
开发者ID:sunspidersp1,项目名称:Questionnaire,代码行数:25,代码来源:PmController.php

示例3: usermanagerAction

 public function usermanagerAction()
 {
     $oper = $this->request->getPost('oper', 'string');
     if ($oper == 'edit') {
         $id = $this->request->getPost('id', 'int');
         $username = $this->request->getPost('username', 'string');
         $password = $this->request->getPost('password', 'string');
         $auth = $this->request->getPost('auth', 'int');
         $name = $this->request->getPost('name', 'string');
         $phone = $this->request->getPost('phone', 'int');
         $email = $this->request->getPost('email', 'email');
         $id_num = $this->request->getPost('id_num', 'string');
         $manager = Manager::findFirst($id);
         $manager->username = $username;
         $manager->password = hash('sha256', $password);
         $manager->auth = $auth;
         $manager->name = $name;
         $manager->id_num = $id_num;
         $manager->phone = $phone;
         $manager->email = $email;
         if (!$manager->save()) {
             foreach ($manager->getMessages() as $message) {
                 echo $message;
             }
         }
     }
     if ($oper == 'del') {
         $id = $this->request->getPost('id', 'int');
         $manager = Manager::findFirst($id);
         if (!$manager->delete()) {
             foreach ($manager->getMessages() as $message) {
                 echo $message;
             }
         }
     }
 }
开发者ID:sify21,项目名称:Question,代码行数:36,代码来源:AdminController.php

示例4: checkUsername

 public static function checkUsername($username)
 {
     $manager = Manager::findFirst(array("username=:username:", "bind" => array("username" => $username)));
     return $manager;
 }
开发者ID:Brucewyh,项目名称:Questionnaire,代码行数:5,代码来源:Manager.php

示例5: updateAction

 public function updateAction()
 {
     $this->view->disable();
     $oper = $this->request->getPost('oper', 'string');
     if ($oper == 'edit') {
         //edit
         //修改之前应该判断数据库中是否已经存在记录 -- 目前在前端进行判定2015-9-12
         $id = $this->request->getPost('id', 'int');
         $project = Project::findFirst($id);
         $project->name = $this->request->getPost('name', 'string');
         #项目开始时间不可变更
         $project->begintime = $this->request->getPost('begintime', 'string');
         $project->endtime = $this->request->getPost('endtime', 'string');
         $project->description = $this->request->getPost('description', 'string');
         $manager = Manager::findFirst(array('project_id=?0', 'bind' => array($id)));
         $manager->name = $this->request->getPost('manager_name', 'string');
         $manager->username = $this->request->getPost('manager_username', 'string');
         $manager->password = $this->request->getPost('manager_password', 'string');
         #时间检查
         if (strtotime($project->begintime) >= strtotime($project->endtime)) {
             $this->dataReturn(array('error' => '项目结束时间与开始时间冲突'));
             return;
         }
         try {
             AdminDB::updateManager($manager);
             AdminDB::updateProject($project);
         } catch (Exception $e) {
             $this->dataReturn(array('error' => '项目信息更新失败'));
             return;
         }
         $this->dataReturn(array('flag' => true));
         return;
     } else {
         if ($oper == 'del') {
             //del
             //需要添加判断是否能被删除 --目前还未添加相应的判定
             $id = $this->request->getPost('id', 'int');
             $project_info = Project::findFirst($id);
             if (!isset($project_info->id)) {
                 $this->dataReturn(array('error' => '项目编号不存在'));
                 return;
             } else {
                 #判断项目状态,如果不是项目的初始状态则禁止删除
                 if ($project_info->state != 0) {
                     $this->dataReturn(array('error' => '项目经理已配置了项目,不能被删除'));
                     return;
                 } else {
                     try {
                         AdminDB::delproject($id);
                     } catch (Exception $e) {
                         $this->dataReturn(array('error' => '项目删除失败'));
                         return;
                     }
                     $this->dataReturn(array('flag' => true));
                     return;
                 }
             }
         } else {
             //
         }
     }
 }
开发者ID:sunxfancy,项目名称:Questionnaire,代码行数:62,代码来源:AdminController.php

示例6: newpasswordAction

 public function newpasswordAction()
 {
     $this->view->disable();
     if ($this->session->has('reset') && $this->request->isPost()) {
         if ($this->session->get('reset') == 'resetpass') {
             $password = $this->request->getPost('password', 'string');
             $id = $this->session->get('reset_id');
             $manager = Manager::findFirst($id);
             if ($manager != false) {
                 $manager->password = hash('sha256', $password);
                 if ($manager->save()) {
                     $this->session->remove("reset");
                     $this->session->remove("reset_id");
                     $this->flash->success('成功修改密码');
                 } else {
                     foreach ($manager->getMessages() as $message) {
                         $this->flash->error($message);
                     }
                 }
             } else {
                 $this->flash->error("用户不存在");
             }
         }
     }
     $this->response->redirect('managerlogin');
 }
开发者ID:sify21,项目名称:Question,代码行数:26,代码来源:ManagerloginController.php


注:本文中的Manager::findFirst方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。