Ejemplo n.º 1
0
 public function update(DomainObject $page)
 {
     $id = $page->getId();
     $title = $page->getTitle();
     $content = $page->getContent();
     $sql = 'UPDATE page
         SET title = ?, content = ?
         WHERE id = ?';
     $this->database->connect();
     $this->database->query($sql)->execute(array($title, $content, $id));
     $this->database->close();
 }
Ejemplo n.º 2
0
 public function find(DomainObject $user)
 {
     $id = $user->getId();
     $username = $user->getUsername();
     $sql = 'SELECT id, username, password
         FROM user';
     if ($id) {
         $sql .= ' WHERE id = ?';
         $parameters = array($id);
     } else {
         if ($username) {
             $sql .= ' WHERE username = ?';
             $parameters = array($username);
         }
     }
     $this->database->connect();
     $this->database->query($sql)->execute($parameters, PDO::FETCH_INTO, $user)->fetch();
     $this->database->close();
 }