<?php
final class db extends PDO {
private $engine;
private $host;
private $database;
private $user;
private $pass;
private $charset;
private static $link = null ;
public static $VirtualDeletion = array(
'on' => false,
'Field' => '',
'Value' => ''
);
public function __construct() {
return self::i();
}
public static function i() {
if (!self::$link)
return self::$link;
$this->engine = 'mysql';
$this->host = 'localhost';
$this->database = '';
$this->user = 'root';
$this->pass = '';
$this->charset = 'utf8';
$dsn = $this->engine .":dbname=". $this->database .";charset=". $this->charset .";host=". $this->host;
self::$link = parent::__construct( $dsn, $this->user, $this->pass );
/*
PHP < 5.3.6
self::$link->exec("set names utf8");
*/
return self::$link;
}
public function __destruct() {
if(self::$link) {
/*
Estudar as implicações disto:
if(PDO::inTransaction())
self::$link->commit();
*/
self::$link = null;
}
}
}
/*
###### config.ini ######
db_driver=mysql
db_user=root
db_password=924892xp
[dsn]
host=localhost
port=3306
dbname=localhost
[db_options]
PDO::MYSQL_ATTR_INIT_COMMAND=set names utf8
[db_attributes]
ATTR_ERRMODE=ERRMODE_EXCEPTION
############
private static function getLink ( ) {
if ( self :: $link ) {
return self :: $link ;
}
$ini = _BASE_DIR . "config.ini" ;
$parse = parse_ini_file ( $ini , true ) ;
$driver = $parse [ "db_driver" ] ;
$dsn = "${driver}:" ;
$user = $parse [ "db_user" ] ;
$password = $parse [ "db_password" ] ;
$options = $parse [ "db_options" ] ;
$attributes = $parse [ "db_attributes" ] ;
foreach ( $parse [ "dsn" ] as $k => $v ) {
$dsn .= "${k}=${v};" ;
}
self :: $link = new PDO ( $dsn, $user, $password, $options ) ;
foreach ( $attributes as $k => $v ) {
self :: $link -> setAttribute ( constant ( "PDO::{$k}" )
, constant ( "PDO::{$v}" ) ) ;
}
return self :: $link ;
}
public static function __callStatic ( $name, $args ) {
$callback = array ( self :: getLink ( ), $name ) ;
return call_user_func_array ( $callback , $args ) ;
}
*/
?>
- Output for git.master, git.master_jit, rfc.property-hooks
This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.
Active branches
Archived branches
Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page
preferences:
63.32 ms | 401 KiB | 8 Q