public function fetch($email)
 {
     $db = new Database();
     $table = new UserTable();
     $table->Create($db);
     $url = null;
     $sql = "Select " . UserTable::Photo_URL . " from " . UserTable::TableName . " where " . UserTable::UserName . "=:email OR " . UserTable::ID . "=:email";
     $stmt = $db->prepare($sql);
     $stmt->bindValue(":email", addslashes(strtolower(trim($email))));
     $status = $stmt->execute();
     if ($status) {
         $row = $stmt->fetch(Database::FETCH_ASSOC);
         $url = $row[UserTable::Photo_URL];
         if ($url != null) {
             $url = IMAGE_PROFILE_DIR . $url;
         }
     } else {
         print_r($stmt->errorInfo());
     }
     return $url;
 }
Exemplo n.º 2
0
 public function fetch($email)
 {
     if ($this->validated($email)) {
         //Try Create the database table
         $this->database = new Database();
         $table = new UserTable();
         $table->Create($this->database);
         $columns = " " . UserTable::FullName . "," . UserTable::ID . "," . UserTable::Photo_URL . "," . UserTable::RegisterDate . "," . UserTable::Gender . "," . UserTable::LastUpdateDate . "," . UserTable::VerificationCode . "," . UserTable::UserName . " ";
         $query = "Select {$columns} from " . UserTable::TableName . " where " . UserTable::UserName . " =:email OR " . UserTable::ID . "=:email";
         $stmt = $this->database->prepare($query);
         $stmt->bindValue(":email", addslashes(strtolower(trim($email))));
         $aBool = $stmt->execute();
         if ($aBool) {
             if ($stmt->rowCount() > 0) {
                 $fetchRow = $stmt->fetch(Database::FETCH_ASSOC);
                 $fetchRow[UserTable::Photo_URL] = IMAGE_PROFILE_DIR . $fetchRow[UserTable::Photo_URL];
                 return $fetchRow;
             } else {
                 $this->__message = "There is no username with the give email address [{$email}]";
             }
         }
     }
     return null;
 }