Example #1
0
 public function userExists(UserDao $user)
 {
     try {
         $sql = "SELECT u.id FROM " . USERTABLE . " AS u" . " JOIN " . USERCREDTABLE . " AS uc ON uc.user_id=u.id" . " WHERE uc.username=:username";
         $stmt = $this->dbh->prepare($sql);
         $stmt->setFetchMode(PDO::FETCH_ASSOC);
         $stmt->execute(array(':username' => $user->username));
         $rowCount = count($stmt->fetchAll());
         $stmt->closeCursor();
         return $rowCount > 0;
     } catch (PDOException $ex) {
         $syslog = new Syslog();
         $syslog->write($ex);
         $syslog->shutdown();
         return $this->error(ErrorCodes::USER_GENERIC_ERROR, "Failed to find user");
     }
 }