public function __construct() { if (!php_Boot::$skip_constructor) { $this->db = new zcale_sys_db_Database("zcale"); $this->cnx = sys_db_Mysql::connect(_hx_anonymous(array("host" => "localhost", "user" => "root", "pass" => "root", "database" => $this->db->name, "port" => null, "socket" => null))); } }
public function __construct($dbtype = null, $host = null, $port = null, $socket = null, $user = null, $pass = null, $database = null, $trase = null) { if (!php_Boot::$skip_constructor) { $timer = null; $stoptime = null; $profiler = system_base_Profiler::get_instance(); $db_config = ""; $config_path = _hx_string_or_null(system_base_Wet_base::$conf_path) . "database.xml"; try { $db_config = sys_io_File::getContent($config_path); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e = $_ex_; throw new HException(new system_base_NoFileError(_hx_string_or_null($config_path) . " does not exist or cannot be opened for reading")); } $xml = Xml::parse($db_config); $config = new haxe_xml_Fast($xml->firstElement()); if ($dbtype === null) { $dbtype = $config->node->resolve("type")->get_innerHTML(); } else { $dbtype = $dbtype; } if ($user === null) { $user = $config->node->resolve("user")->get_innerHTML(); } else { $user = $user; } if ($pass === null) { $pass = $config->node->resolve("pass")->get_innerHTML(); } else { $pass = $pass; } if ($port === null) { $port = Std::parseInt($config->node->resolve("port")->get_innerHTML()); } else { $port = $port; } if ($socket === null) { $socket = $config->node->resolve("socket")->get_innerHTML(); } else { $socket = $socket; } if ($database === null) { $database = $config->node->resolve("schema")->get_innerHTML(); } else { $database = $database; } $timer = new system_base_Timers(null); switch ($dbtype) { case "mysql": if ($host === null) { $host = $config->node->resolve("host")->get_innerHTML(); } else { $host = $host; } if ($trase) { haxe_Log::trace("Attempting connection to " . "MySQL " . _hx_string_or_null($user) . "@" . _hx_string_or_null($host), _hx_anonymous(array("fileName" => "Database.hx", "lineNumber" => 115, "className" => "system.base.Database", "methodName" => "new"))); } try { if (system_base_Database::$cnx === null) { system_base_Database::$cnx = sys_db_Mysql::connect(_hx_anonymous(array("host" => $host, "port" => $port, "user" => $user, "pass" => $pass, "socket" => $socket, "database" => $database))); } } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e1 = $_ex_; throw new HException(new system_base_NoConnectionError($e1)); return; } $stoptime = $timer->stop(); break; case "sqlite": if ($host === null) { $host = $config->node->resolve("host")->get_innerHTML(); } else { $host = $host; } if (_hx_index_of($host, "/", null) === -1) { $host = _hx_string_or_null(system_base_Wet_base::$datastore_path) . _hx_string_or_null($host); } else { $host = $host; } if ($trase) { haxe_Log::trace("Attempting connection to " . "SQLite@" . _hx_string_or_null($host), _hx_anonymous(array("fileName" => "Database.hx", "lineNumber" => 150, "className" => "system.base.Database", "methodName" => "new"))); } system_base_Database::$cnx = sys_db_Sqlite::open($host); $stoptime = $timer->stop(); break; default: throw new HException(new system_base_NoSuchDbexception($dbtype)); break; } $profiler->increment("CON", $stoptime, null); } }