public static function init($dbConf = false) { include __DIR__ . '/../config.php'; try { $current = preg_split('/\\:/', $current); if (count($current) < 2 || !isset($db[$current[0]][$current[1]])) { self::$dbErrMsg = ErrorCatcher::errorMsg('config_error'); throw new ErrorCatcher(self::$dbErrMsg); } } catch (ErrorCatcher $e) { $excParm['e'] = $e; echo ErrorCatcher::fire($excParm); } self::$driver = $current[0]; $currentConf = $db[$current[0]][$current[1]]; if (!$dbConf) { if (is_null(self::$dbconf)) { self::$dbconf = $currentConf; self::$driver = ucfirst(self::$driver); $_driver = 'Db\\drivers\\My\\' . self::$driver; $_driver::init($currentConf); } } else { self::$dbconf = $config; } }
/** * executes the query * * @type internal method * @return void */ protected static function execute() { try { self::$dbLink = mysql_connect(self::$dbconf['hostname'], self::$dbconf['username'], self::$dbconf['password']); if (!self::$dbLink) { self::$dbErr = 'Check database connections info'; throw new ErrorCatcher(self::$dbErr); } mysql_select_db(self::$dbconf['database'], self::$dbLink); mysql_set_charset('utf8', self::$dbLink); self::$Queries[md5(self::$query)]['query'] = self::$query; $start = microtime(); self::$qResult = mysql_query(self::$query); $stop = microtime(); self::$Queries[md5(self::$query)]['duration'] = number_format($stop - $start, 4, ',', '.'); if (!self::$qResult) { self::$dbErr = mysql_error(); throw new ErrorCatcher(self::$dbErr); } self::$affected_rows = mysql_affected_rows(); self::emptySqlVars(); } catch (ErrorCatcher $e) { echo ErrorCatcher::fire(array('e' => $e, 'q' => self::$query)); } }