當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。