<?php class DB_Personas { private static $_driver = DRIVER; private static $_port = PORT; private static $_server = SERVER; private static $_dbname = DBNAME; private static $_user = USER; private static $_passwd = PASSWD; private static $_connect;
// private function DB_Personas(){}
public static function Connection(){ //este seria el mètodo getInstance, el que permite la conexiòn a la base de datos $dsn= self::$_driver.":host=".self::$_server.":".self::$_port.";dbname=".self::$_dbname; if(!isset(self::$_connect)){ self::$_connect=new PDO($dsn,self::$_user,self::$_passwd, [PDO::ATTR_PERSISTENT=>TRUE]); self::$_connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } return self::$_connect; } public function Exec($sql){ return self::$_connect->exec($sql); } public function Query($sql){ return self::$_connect->query($sql); } public function _clone(){ trigger_error('Este objeto no se puede clonar', E_USER_ERROR); }
}
?>