Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $path = dirname( __FILE__ );
- require_once( $path . '/config.php');
- class DB
- {
- private static $conexao;
- public static function connect()
- {
- if(!isset(self::$conexao))
- {
- try{
- self::$conexao = new PDO('mysql:host='.HOST.';dbname='.DB_NAME, USER, PASS);
- self::$conexao->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- self::$conexao->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
- }
- catch(PDOException $e)
- {
- echo $e->getMessage();
- }
- return self::$conexao;
- }
- }
- public static function prepare($sql)
- {
- return self::connect()->prepare($sql);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement