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


PHP Department::save方法代码示例

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


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

示例1: doSave

 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aDepartment !== null) {
             if ($this->aDepartment->isModified() || $this->aDepartment->isNew()) {
                 $affectedRows += $this->aDepartment->save($con);
             }
             $this->setDepartment($this->aDepartment);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = InstructorPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = InstructorPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += InstructorPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         if ($this->collCourseInstructorAssociations !== null) {
             foreach ($this->collCourseInstructorAssociations as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collInstructorDetails !== null) {
             foreach ($this->collInstructorDetails as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:rafd,项目名称:SkuleCourses,代码行数:65,代码来源:BaseInstructor.php

示例2: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Department();
     if (isset($_POST['Department'])) {
         $model->attributes = $_POST['Department'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->department_id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:houyf,项目名称:class_system,代码行数:15,代码来源:DepartmentController.php

示例3: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Department();
     if (isset($_POST['Department'])) {
         $model->attributes = $_POST['Department'];
         if ($model->save()) {
             Yii::app()->user->setFlash('success', '创建成功');
             $this->redirect(array('update', 'id' => $model->d_id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:CNAEF,项目名称:go9999_v2,代码行数:16,代码来源:DepartmentController.php

示例4: store

 /**
  * Store a newly created branch in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Department::$rules, Department::$messages);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $department = new Department();
     $department->department_name = Input::get('name');
     $department->organization_id = '1';
     $department->save();
     return Redirect::route('departments.index');
 }
开发者ID:kenkode,项目名称:xaraerp,代码行数:17,代码来源:DepartmentsController.php

示例5: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Department();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Department'])) {
         $model->attributes = $_POST['Department'];
         if ($model->save()) {
             $this->redirect(array('admin'));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:emisdb,项目名称:tffin,代码行数:17,代码来源:DepartmentController.php

示例6: executeAdd

 public function executeAdd(sfWebRequest $request)
 {
     if ($request->isMethod('Post')) {
         $department = new Department();
         $department->setTitle($request->getParameter('title'));
         //$department->setDescription($request->getParameter('description'));
         $department->setStatus(Constant::RECORD_STATUS_ACTIVE);
         $department->save();
         $this->getUser()->setFlash('SUCCESS_MESSAGE', Constant::RECORD_ADDED_SUCCESSFULLY);
         $this->redirect('Department/list');
     }
     //end if
 }
开发者ID:lejacome,项目名称:hospital-mgt,代码行数:13,代码来源:actions.class.php

示例7: store

 /**
  * Store a newly created resource in storage.
  * POST /department
  *
  * @return Response
  */
 public function store()
 {
     Input::merge(array_map('trim', Input::all()));
     $input = Input::all();
     $validation = Validator::make($input, Department::$rules);
     if ($validation->passes()) {
         $department = new Department();
         $department->department = strtoupper(Input::get('department'));
         $department->save();
         return Redirect::route('department.index')->with('class', 'success')->with('message', 'Record successfully created.');
     } else {
         return Redirect::route('department.create')->withInput()->withErrors($validation)->with('class', 'error')->with('message', 'There were validation error.');
     }
 }
开发者ID:jcyanga28,项目名称:project-reference,代码行数:20,代码来源:DepartmentController.php

示例8: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Department();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Department'])) {
         $model->attributes = $_POST['Department'];
         if ($model->save()) {
             $this->audit->logAudit(Yii::app()->user->id, new DateTime(), Constants::AUDITORIA_OBJETO_DEPARTAMENTO, Constants::AUDITORIA_OPERACION_ALTA, $model->id);
             $this->render('/site/successfullOperation', array('header' => 'Departamento creado con éxito', 'message' => 'Haga click en volver para regresar a la gestión de departamentos', 'returnUrl' => Yii::app()->createUrl('department/admin'), 'viewUrl' => Yii::app()->createUrl("department/view", array("id" => $model->id))));
             return;
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:MRodriguez08,项目名称:yii-bundles-app,代码行数:19,代码来源:DepartmentController.php

示例9: actionCreate

 public function actionCreate()
 {
     $model = new Department();
     $model->company_id = $this->companyId;
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = Yii::app()->request->getPost('Department');
         $model->create_at = date('Y-m-d H:i:s', time());
         $model->update_at = date('Y-m-d H:i:s', time());
         if ($model->save()) {
             Yii::app()->user->setFlash('success', yii::t('app', '添加成功'));
             $this->redirect(array('department/index', 'companyId' => $this->companyId));
         }
     }
     $printers = $this->getPrinterList();
     $this->render('create', array('model' => $model, 'printers' => $printers));
 }
开发者ID:song-yuan,项目名称:wymenujp,代码行数:16,代码来源:DepartmentController.php

示例10: testFind

 function testFind()
 {
     //Arrange
     $name = "Math";
     $id = 1;
     $test_department = new Department($name, $id);
     $test_department->save();
     $name2 = "Business";
     $id2 = 2;
     $test_department2 = new Department($name2, $id2);
     $test_department2->save();
     //Act
     $id = $test_department->getId();
     $result = Department::find($id);
     //Assert
     $this->assertEquals($test_department, $result);
 }
开发者ID:jlbethel,项目名称:Registrar_test,代码行数:17,代码来源:DepartmentTest.php

示例11: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Department();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Department'])) {
         $model->attributes = $_POST['Department'];
         if (User::getMyCompany() == $model->company_id || Yii::app()->user->role == 1) {
             if ($model->save()) {
                 $this->redirect(array('view', 'id' => $model->id));
             }
         } else {
             throw new CHttpException(403, 'У вас закрыт доступ к редактированию этой организации');
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:griffindor,项目名称:new-inventory,代码行数:21,代码来源:DepartmentController.php

示例12: store

 public function store()
 {
     Auth::isAdminOrDie(App::$instance);
     Token::checkToken();
     $request = $this->request->request;
     $this->validator->validate(['Префикс' => [$request->get('prefix'), 'required|int'], 'Название' => [$request->get('name'), 'required|max(255)']]);
     //if no passes
     if (!$this->validator->passes()) {
         App::$instance->MQ->setMessage($this->validator->errors()->all());
         ST::redirect("back");
     }
     $dep = new Department();
     $dep->fill($request->all());
     $dep->save();
     App::$instance->MQ->setMessage("Успешно создано");
     App::$instance->log->logWrite(LOG_CONFIG_CHANGE, 'Добавлено подразделение' . $dep->name);
     ST::redirectToRoute('Departments/index');
 }
开发者ID:inilotic,项目名称:vks_nodes_core,代码行数:18,代码来源:Departments_controller.php

示例13: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Department();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Department'])) {
         $model->attributes = $_POST['Department'];
         $model->branch = Yii::app()->session->get('branch_id');
         $model->created_by = Yii::app()->session->get('user_id');
         $model->created_on = date('Y-m-d H:i:s');
         $model->modified_by = Yii::app()->session->get('user_id');
         $model->modified_on = date('Y-m-d H:i:s');
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:ndrahawk,项目名称:Biruni-ERP,代码行数:22,代码来源:DepartmentController.php

示例14: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Department();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Department'])) {
         $model->attributes = $_POST['Department'];
         if ($model->save()) {
             date_default_timezone_set("Asia/Manila");
         }
         $activity = new Activity();
         $activity->act_desc = 'Added Another Department';
         $activity->act_datetime = date('Y-m-d G:i:s');
         $activity->act_by = User::model()->findByPK(Yii::app()->user->name)->emp_id;
         $activity->save();
         $this->redirect(array('view', 'id' => $model->dept_id));
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:JexIboy,项目名称:lis-pglu,代码行数:23,代码来源:DepartmentController.php

示例15: store

 /**
  * Store a newly created resource in storage.
  * POST /department
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make(Input::all(), Department::$rules);
     $row = Department::where('id_dept', '=', Input::get('id_dept'));
     if ($validator->fails()) {
         return Redirect::to('department')->withErrors($validator)->withInput(Input::all());
     } else {
         if (Department::where('id_dept', '=', Input::get('id_dept'))->exists()) {
             $department = Department::find(Input::get('id_dept'));
             $department->nm_dept = Input::get('nm_dept');
             $department->save();
             Session::flash('message', 'Successfully updated Department!');
             return Redirect::to('department');
         } else {
             $department = new Department();
             $department->id_dept = Input::get('id_dept');
             $department->nm_dept = Input::get('nm_dept');
             $department->save();
             Session::flash('message', 'Successfully created Department!');
             return Redirect::to('department');
         }
     }
     //
 }
开发者ID:shimohira,项目名称:supplier,代码行数:30,代码来源:DepartmentController.php


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