Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Database {
- private static $link = null;
- private static function getLink() {
- if (self::$link) {
- return self::$link;
- }
- $ini = "/home/world/private/mmn_mvsoftware.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);
- self::$link->Exec("SET AUTOCOMMIT=0");
- self::$link->Exec("SET CHARACTER SET utf8");
- foreach ($attributes as $k => $v) {
- self::$link->setAttribute(constant("PDO::{$k}"), constant("PDO::{$v}"));
- }
- self::$link->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
- return self::$link;
- }
- public static function __callStatic($name, $args) {
- $callback = array(
- self::getLink(),
- $name
- );
- $res = call_user_func_array($callback, $args);
- return $res;
- }
- }
- $Query = Database::Prepare("SELECT CURRENT_DATE AS DATA_SYS, CURRENT_TIME AS HORA_SYS");
- $Query->Execute();
Add Comment
Please, Sign In to add comment