本文整理汇总了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 ...
}
}
}
}
示例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;
}
}
}
}
示例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;
}
}
}
}
示例4: checkUsername
public static function checkUsername($username)
{
$manager = Manager::findFirst(array("username=:username:", "bind" => array("username" => $username)));
return $manager;
}
示例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 {
//
}
}
}
示例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');
}