Exemple #1
0
 static function login(&$user)
 {
     $table = substr(strrchr(static::$class, "\\"), 1) . 's';
     $sql = "SELECT idUsuario, nome, email, tipo, status FROM {$table} WHERE email = ? and senha = ?";
     $stmt = Conexao::getConnection()->prepare($sql);
     $stmt->bindValue(1, $user->email);
     $stmt->bindValue(2, $user->senha);
     $stmt->setFetchMode(PDO::FETCH_CLASS, static::$class);
     $stmt->execute();
     if ($stmt->rowCount() > 0) {
         $user = $stmt->fetch();
     } else {
         $user = null;
     }
 }
Exemple #2
0
 /**
  * Get single one object of database
  * @param  int $id
  * @return Object 
  */
 static function get($id)
 {
     $table = substr(strrchr(static::$class, "\\"), 1) . 's';
     $pk = static::$props['PK'];
     $sql = "SELECT * FROM {$table} WHERE {$pk} = ?";
     $stmt = Conexao::getConnection()->prepare($sql);
     $stmt->bindValue(1, $id);
     $stmt->setFetchMode(PDO::FETCH_CLASS, static::$class);
     $stmt->execute();
     return $stmt->fetch();
 }