[#] hm X_Shell Backd00r [#]
<?php
class Conexion{
private static $instancia;
private $conex;
private function __construct(){
try{
$this->conex = new PDO('mysql:host=localhost;dbname=c35autodromomabed','c35automabed','Bich@soft1');
$this->conex->exec("SET CHARACTER SET utf8");
$this->conex->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}catch(PDOExeption $e){
print "Error!:".$e->getMessage();
die();
}
}
public function prepare($sql){
return $this->conex->prepare($sql);
}
public static function singleton_conexion(){
if(!isset(self::$instancia)){
$miCalse = __CLASS__;
self::$instancia = new $miCalse;
}
return self::$instancia;
}
public function __clone(){
trigger_error('La clonación de este objeto no está permitida', E_USER_ERROR);
}
public function lastId($id, $tabla){
try{
$sql = "SELECT MAX($id) AS id FROM $tabla";
$query = $this->conex->prepare($sql);
$query->execute();
$result = $query->fetch(PDO::FETCH_ASSOC);
return $result['id'];
}catch(PDOExeption $e){
print "Error!:".$e->getMessage();
die();
}
}
}
?>
Mr.hm X_Shell Backd00r 1.0, Coded By Mr.hm X_Shell Backd00r