I am using the following class to connect to the MySQL database
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;
}
}
I run this way:
$Query = Database::Prepare("SELECT CURRENT_DATE AS DATA_SYS, CURRENT_TIME AS HORA_SYS");
$Query->Execute();
It returns me the following message:
Call to undefined method Database :: Prepare ()
It happens that I have Ubuntu servers and CENTOS with PHP5.3 that work in a good, but in the hosting of Locaweb give me this message and will not even pray brava