예제 #1
0
파일: User.php 프로젝트: venril/blogger3
 public function update(UserModel $user)
 {
     $sql = 'UPDATE user SET
             email=:email,
             username=:username,
             password=:password,
             firstname=:firstname,
             lastname=:lastname,
             birthdate=:birthdate,
             isActive=:isActive
             WHERE id=:id
            ';
     $this->getDb()->beginTransaction();
     try {
         $stmt = $this->getDb()->prepare($sql);
         $stmt->execute(array('email' => $user->getEmail(), 'username' => $user->getUsername(), 'password' => $user->getPassword(), 'firstname' => $user->getFirstname(), 'lastname' => $user->getLastname(), 'birthdate' => $user->getBirthdate()->format('Y-m-d'), 'isActive' => $user->getIsActive(), 'id' => (int) $user->getId()));
         $this->getDb()->commit();
     } catch (PDOException $e) {
         $this->getDb()->rollBack();
         throw $e;
     }
 }
예제 #2
0
파일: User.php 프로젝트: venril/blogger2
 public function insert(UserModel $user)
 {
     $sql = 'INSERT INTO user VALUES (' . 'NULL, ' . "'" . $user->getEmail() . "'," . "'" . $user->getUsername() . "'," . "'" . $user->getPassword() . "'," . "'" . $user->getFirstname() . "'," . "'" . $user->getLastname() . "'," . "'" . $user->getBirthdate()->format('Y-m-d') . "'," . "'" . (int) $user->getIsActive() . "'" . ")";
     echo $sql;
     $this->getDb()->exec($sql);
 }