Guest User

Untitled

a guest
Feb 6th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. $database = database::select("SELECT * FROM eventos");
  2.  
  3. <?php
  4. class database{
  5.  
  6. protected static $driver = 'mysql';
  7. protected static $host = 'localhost';
  8. protected static $port = 3306;
  9. protected static $user = 'root';
  10. protected static $pass = 'vertrigo';
  11. protected static $database = 'noweb';
  12. public $link = null;
  13.  
  14. public function __construct(){
  15.  
  16. try{
  17.  
  18. $this->link = new PDO(self::$driver.":host=".self::$host.";port=".self::$port.";dbname=".self::$database, self::$user, self::$pass);
  19.  
  20. }catch(PDOException $i){
  21.  
  22. die("Ocorreu um erro ao fazer conexão: <code>".$i->getMessage()."</code>");
  23. }
  24.  
  25. }
  26.  
  27. static function select($sql){
  28.  
  29. $query = $this->link->query($sql);
  30. $rs = $query->fetchAll(PDO::FETCH_OBJ) or die(print_r($query->errorInfo(), true));
  31.  
  32. return $rs;
  33. }
  34. }
  35.  
  36. ?>
  37.  
  38. database::FUNÇÃO('parametros');
Add Comment
Please, Sign In to add comment