예제 #1
0
 /**
  * Saves a user into the database.
  *
  * @param \VeryGoodTrip\Domain\User $user The user to save
  */
 public function save(User $user)
 {
     $userData = array('user_email' => $user->getEmail(), 'user_salt' => $user->getSalt(), 'user_password' => $user->getPassword(), 'user_role' => $user->getRole(), 'user_lastname' => $user->getLastname(), 'user_firstname' => $user->getFirstname(), 'user_address' => $user->getAddress(), 'user_town' => $user->getTown(), 'user_zipcode' => $user->getZipcode());
     if ($user->getId()) {
         $this->getDb()->update('user', $userData, array('user_id' => $user->getId()));
     } else {
         // The user has never been saved : insert it
         $this->getDb()->insert('user', $userData);
         // Get the id of the newly created user and set it on the entity.
         // $id = $this->getDb()->lastInsertId();
         $user->setEmail($user->getEmail());
     }
 }