本文整理汇总了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;
}
示例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));
}
示例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));
}
示例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');
}
示例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));
}
示例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
}
示例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.');
}
}
示例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));
}
示例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));
}
示例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);
}
示例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));
}
示例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');
}
示例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));
}
示例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));
}
示例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');
}
}
//
}