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


PHP Person::save方法代码示例

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


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

示例1: add_persona

 public function add_persona()
 {
     $inputs = Input::all();
     $rules = array('persona_cid' => 'required|integer|unique:persona,persona_cid', 'persona_primer_apellido' => 'required|max:50|alpha:persona,persona_primer_apellido', 'persona_segundo_apellido' => 'required|max:50|alpha:persona,persona_segundo_apellido', 'persona_primer_nombre' => 'required|max:50|alpha:persona,persona_primer_nombre', 'persona_segundo_nombre' => 'max:50|alpha:persona,persona_segundo_nombre', 'persona_sexo' => 'required|max:1|alpha:persona,persona_sexo', 'persona_fecha_nac' => 'required|date:persona,persona_fecha_nac', 'persona_grado_instruccion' => 'required|max:20|alpha:persona,persona_grado_instruccion', 'persona_mail' => 'required|max:50|email:persona,persona_mail', 'persona_departamento' => 'alpha|max:50:persona,persona_departamento');
     $validator = Validator::make($inputs, $rules);
     if ($validator->fails()) {
         return Redirect::back()->withInput()->withErrors($validator);
     } else {
         $persona = new Person();
         $persona->persona_cid = Input::get('persona_cid');
         $persona->persona_primer_apellido = Input::get('persona_primer_apellido');
         $persona->persona_segundo_apellido = Input::get('persona_segundo_apellido');
         $persona->persona_primer_nombre = Input::get('persona_primer_nombre');
         if (Input::get('persona_segundo_nombre') != 'NULL') {
             $persona->persona_segundo_nombre = Input::get('persona_segundo_nombre');
         } else {
             $persona->persona_segundo_nombre = null;
         }
         $persona->persona_sexo = Input::get('persona_sexo');
         $persona->persona_fecha_nac = Input::get('persona_fecha_nac');
         $persona->persona_grado_instruccion = Input::get('persona_grado_instruccion');
         $persona->persona_mail = Input::get('persona_mail');
         if (Input::get('persona_departamento') != 'NULL') {
             $persona->persona_departamento = Input::get('persona_departamento');
         } else {
             $persona->persona_departamento = NULL;
         }
         $persona->fk_profesion = Input::get('fk_profesion');
         $persona->fk_cargo = Input::get('fk_cargo');
         $persona->fk_lugar = Input::get('fk_lugar');
         if (Input::get('fk_persona_a_quien_autorizo') != 'NULL') {
             $persona->fk_persona_a_quien_autorizo = Input::get('fk_persona_a_quien_autorizo');
             $persona->fk_persona_quien_me_autorizo = NULL;
             $persona->persona_es_autorizado = FALSE;
             $persona->save();
             $persona_a_quien_autorizo = Person::find($persona->fk_persona_a_quien_autorizo);
             $persona_a_quien_autorizo->persona_es_autorizado = TRUE;
             $persona_a_quien_autorizo->fk_persona_quien_me_autorizo = $persona->id;
             $persona_a_quien_autorizo->save();
             return Redirect::to('persona');
         } else {
             $persona->fk_persona_a_quien_autorizo = NULL;
             $persona->fk_persona_quien_me_autorizo = NULL;
             $persona->persona_es_autorizado = FALSE;
             $persona->save();
             return Redirect::to('persona');
         }
         return Redirect::to('persona');
     }
 }
开发者ID:bmrpas,项目名称:SHREDDER,代码行数:50,代码来源:PersonaController.php

示例2: create_person

 public function create_person()
 {
     $form = $this->get_form();
     build_validator_from_form($form);
     if ($this->form_validation->run()) {
         $this->db->trans_begin();
         $person_data = $this->input->post('person');
         $person = new Person();
         $person->from_array($person_data, array('name', 'surname', 'login', 'organisation', 'admin'));
         $person->password = sha1($person_data['password']);
         $person->enabled = 1;
         $group = new Group();
         $group->get_by_id((int) $person_data['group_id']);
         if ($person->save($group) && $this->db->trans_status()) {
             $this->db->trans_commit();
             add_success_flash_message('Osoba menom <strong>' . $person_data['name'] . ' ' . $person_data['surname'] . '</strong> s loginom <strong>' . $person_data['login'] . '</strong> bola vytvorená s ID <strong>' . $person->id . '</strong>.');
             redirect(site_url('persons'));
         } else {
             $this->db->trans_rollback();
             add_error_flash_message('Osobu sa nepodarilo vytvoriť, skúste to znovu neskôr.');
             redirect(site_url('persons/new_person'));
         }
     } else {
         $this->new_person();
     }
 }
开发者ID:andrejjursa,项目名称:lstme-ledcoin,代码行数:26,代码来源:persons.php

示例3: 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->aPerson !== null) {
             if ($this->aPerson->isModified() || $this->aPerson->isNew()) {
                 $affectedRows += $this->aPerson->save($con);
             }
             $this->setPerson($this->aPerson);
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = PersonalNotePeer::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->setNew(false);
             } else {
                 $affectedRows += PersonalNotePeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:yasirgit,项目名称:afids,代码行数:46,代码来源:BasePersonalNote.php

示例4: save

    function save()
    {
        global $dbh;
        $returnValue = false;
        if (parent::save()) {
            $query = '
INSERT INTO `employeeDetails` (
	  `uniqueID`
	, `IDNumber`
	, `KRAPIN`
	, `dateOfEmployment`
)
VALUES (
	  "' . mysql_escape_string($this->getUniqueID()) . '"
	, "' . mysql_escape_string($this->getIDNumber()) . '"
	, "' . mysql_escape_string($this->getKRAPIN()) . '"
	, "' . mysql_escape_string($this->getDateOfEmployment()) . '"
)';
            try {
                $dbh->beginTransaction();
                $dbh->exec($query);
                $dbh->commit();
                $returnValue = true;
            } catch (PDOException $e) {
                print "Error!: " . $e->getMessage() . "<br/>";
                die;
            }
            $returnValue = true;
        }
        return $returnValue;
    }
开发者ID:eebrah,项目名称:schoolsys,代码行数:31,代码来源:Employee.class.php

示例5: executeTwitterCallback

 /**
  * Create the person or find it.
  */
 public function executeTwitterCallback(sfWebRequest $request)
 {
     $user = $this->getUser();
     $this->isAuthenticated = false;
     if ($user->isAuthenticated() == true) {
         $this->isAuthenticated = true;
         $guardUser = $user->getGuardUser();
         $guardUserId = $guardUser->getId();
         $token = $user->getAttribute('sfTwitterAuth_oauth_access_token');
         $secret = $user->getAttribute('sfTwitterAuth_oauth_access_token_secret');
         //look for a person with this guard user id already.
         $q = Doctrine_Query::create()->from('Person p')->where('p.sf_guard_user_id = ?', $guardUserId);
         $person = $q->fetchOne();
         $personTable = Doctrine_Core::getTable('Person');
         $person = $personTable->findOneBy('sf_guard_user_id', $guardUserId);
         $this->addedPerson = false;
         $this->personSQLQuery = "GuardUserID={$guardUserId} " . $q->getSqlQuery();
         // . "params = " . print_r($q->getParams(), true);
         if ($person === false) {
             $person = new Person();
             $person->setSfGuardUserId($guardUserId);
             $person->setTwitterToken($token);
             $person->setTwitterSecret($secret);
             $person->save();
             $this->addedPerson = true;
         }
         $personId = $person->getId();
         $user->setPersonId($personId);
         $this->personId = $personId;
         $this->redirect('@homepage');
     }
 }
开发者ID:nathanlon,项目名称:twical,代码行数:35,代码来源:actions.class.php

示例6: systemCompany

 public function systemCompany(&$do, &$errors)
 {
     $user = getCurrentUser();
     $person = new Person();
     $person->load($user->person_id);
     $format = new xmlrpcmsg('elgg.user.newCommunity', array(new xmlrpcval($person->firstname . ' ' . $person->surname, "string"), new xmlrpcval($person->email, "string"), new xmlrpcval($do->company, "string")));
     $client = new xmlrpc_client("_rpc/RPC2.php", "tech2.severndelta.co.uk", 8091);
     $request = $client->send($format);
     if (!$request->faultCode()) {
         $response = $request->value();
         if ($response->structmemexists('owner') && $response->structmemexists('community')) {
             $person->published_username = $response->structmem('owner')->scalarval();
             $person->save();
             $do->published = true;
             $do->published_username = $response->structmem('community')->scalarval();
             $do->published_owner_id = $person->id;
             $do->save();
         } else {
             $errors[] = 'Failed to publish company';
         }
     } else {
         $errors[] = "Code: " . $request->faultCode() . " Reason '" . $request->faultString();
         return false;
     }
     return true;
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:26,代码来源:Publish.php

示例7: save_employee

 public function save_employee(&$person_data, &$employee_data, &$grants_data, $employee_id = FALSE)
 {
     $success = FALSE;
     //Run these queries as a transaction, we want to make sure we do all or nothing
     $this->db->trans_start();
     if (parent::save($person_data, $employee_id)) {
         if (!$employee_id || !$this->exists($employee_id)) {
             $employee_data['person_id'] = $employee_id = $person_data['person_id'];
             $success = $this->db->insert('employees', $employee_data);
         } else {
             $this->db->where('person_id', $employee_id);
             $success = $this->db->update('employees', $employee_data);
         }
         //We have either inserted or updated a new employee, now lets set permissions.
         if ($success) {
             //First lets clear out any grants the employee currently has.
             $success = $this->db->delete('grants', array('person_id' => $employee_id));
             //Now insert the new grants
             if ($success) {
                 foreach ($grants_data as $permission_id) {
                     $success = $this->db->insert('grants', array('permission_id' => $permission_id, 'person_id' => $employee_id));
                 }
             }
         }
     }
     $this->db->trans_complete();
     $success &= $this->db->trans_status();
     return $success;
 }
开发者ID:mnapier,项目名称:opensourcepos,代码行数:29,代码来源:Employee.php

示例8: save

 public function save($deep = true)
 {
     if (!$this->Username) {
         $this->Username = static::getUniqueUsername($this->FirstName, $this->LastName);
     }
     return parent::save($deep);
 }
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:7,代码来源:User.class.php

示例9: add

 public function add()
 {
     $person = new Person();
     $person->save();
     (new Customer())->setPerson($person)->save();
     $this->getRequest()->redirect("person", "edit", array("id" => $person->getId()));
 }
开发者ID:xama5,项目名称:uver-erp,代码行数:7,代码来源:Router.php

示例10: add_post

 public function add_post()
 {
     $person = new Person();
     $person->save();
     (new Employee())->setPerson($person)->setHours($_POST["hours"])->setWage($_POST["wage"])->save();
     $this->getRequest()->redirect("person", "edit", array("id" => $person->getId()));
 }
开发者ID:xama5,项目名称:uver-erp,代码行数:7,代码来源:Router.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 Person();
     $model->attributes = $_POST;
     $result = $model->save();
     $this->sendAjaxResponse($model);
 }
开发者ID:pdooley,项目名称:genesis,代码行数:11,代码来源:PersonController.php

示例12: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $user = new User('passwordset');
     $person = new Person();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['User'], $_POST['Person'])) {
         $person->attributes = $_POST['Person'];
         if ($person->save()) {
             $user->attributes = $_POST['User'];
             $user->person_id = $person->id;
             if ($user->save()) {
                 // Assign a role to the user
                 $command = Yii::app()->db->createCommand();
                 $effectedRows = $command->insert('auth_assignment', array('itemname' => $user->user_role, 'userid' => $user->id, 'bizrule' => '', 'data' => 's:0:"";'));
                 if ($effectedRows == 1) {
                     Yii::app()->user->setFlash('success', Yii::t('user', 'User created and assigned to Role successfuly.'));
                 } else {
                     Yii::app()->user->setFlash('error', Yii::t('user', 'user assignment to Role failed.'));
                 }
                 $this->redirect(array('view', 'id' => $user->id));
             } else {
                 Yii::app()->user->setFlash('error', Yii::t('user', 'user creation failed.'));
             }
         } else {
             Yii::app()->user->setFlash('error', Yii::t('user', 'person creation failed.'));
         }
     }
     $this->render('create', array('user' => $user, 'person' => $person));
 }
开发者ID:nurielmeni,项目名称:nymedia,代码行数:34,代码来源:UserController.php

示例13: save

 public function save()
 {
     try {
         $model = new Person($this->data->id);
         $model->setData($this->data->person);
         $model->save();
         $this->renderPrompt('information', 'OK');
     } catch (\Exception $e) {
         $this->renderPrompt('error', $e->getMessage());
     }
 }
开发者ID:elymatos,项目名称:expressive_fnbr,代码行数:11,代码来源:PersonController.php

示例14: 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->aPassenger !== null) {
             if ($this->aPassenger->isModified() || $this->aPassenger->isNew()) {
                 $affectedRows += $this->aPassenger->save($con);
             }
             $this->setPassenger($this->aPassenger);
         }
         if ($this->aPerson !== null) {
             if ($this->aPerson->isModified() || $this->aPerson->isNew()) {
                 $affectedRows += $this->aPerson->save($con);
             }
             $this->setPerson($this->aPerson);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = CompanionPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = CompanionPeer::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 += CompanionPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         if ($this->collMissionCompanions !== null) {
             foreach ($this->collMissionCompanions as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:yasirgit,项目名称:afids,代码行数:64,代码来源:BaseCompanion.php

示例15: testDelete

 public function testDelete()
 {
     $person = new Person();
     $person->setPersonKindID(1);
     $person->setUsername("timmy");
     $person->setName("Timothy");
     $person->setPhone("000-101-1010");
     $person->save();
     $this->assertTrue(Person::personExists($person->getUsername()) != false);
     $person->delete();
     $this->assertTrue(!Person::personExists($person->getUsername()));
 }
开发者ID:JakeDawkins,项目名称:NiceCatch,代码行数:12,代码来源:personTest.php


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