Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $database = database::select("SELECT * FROM eventos");
- <?php
- class database{
- protected static $driver = 'mysql';
- protected static $host = 'localhost';
- protected static $port = 3306;
- protected static $user = 'root';
- protected static $pass = 'vertrigo';
- protected static $database = 'noweb';
- public $link = null;
- public function __construct(){
- try{
- $this->link = new PDO(self::$driver.":host=".self::$host.";port=".self::$port.";dbname=".self::$database, self::$user, self::$pass);
- }catch(PDOException $i){
- die("Ocorreu um erro ao fazer conexão: <code>".$i->getMessage()."</code>");
- }
- }
- static function select($sql){
- $query = $this->link->query($sql);
- $rs = $query->fetchAll(PDO::FETCH_OBJ) or die(print_r($query->errorInfo(), true));
- return $rs;
- }
- }
- ?>
- database::FUNÇÃO('parametros');
Add Comment
Please, Sign In to add comment