/** * Автоматическое подключение файлов классов. Функция используется при значении константы GL_CLASS_AUTOLOAD = true * @param string $classname имя класса */ function ___autoload($classname) { $class_path = classPath($classname); if (file_exists($class_path)) { require_once $class_path; } }
public static function &Db($ENV) { static $instance; if (!is_object($instance)) { if (!GL_CLASS_AUTOLOAD) { require_once classPath('Db_MySql'); } $file_config = DOC_ROOT . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . $ENV . '_db.php'; if (file_exists($file_config)) { $cfg = (include_once $file_config); } $instance = new Db_MySql($cfg['DB_HOST'], $cfg['DB_USER'], $cfg['DB_PASS'], $cfg['DB_NAME'], false); } return $instance; }
public function query($query, $noresult = false, &$err = null, $logging = true) { $this->result = mysqli_query($this->link, $query); if ($logging && LOG_DATABASE) { global $App; $App->WriteLog($query, LOG_MSG_TYPE_DATABASE, '', false); } if ($this->result == false) { //trigger_error('Ошибка выполнения запроса: "' . $this->error() . '"<br>' . strval($query)); $this->error = 'Ошибка выполнения запроса: "' . $this->error() . '"<br>' . strval($query); return false; } if ($noresult) { // Возвращаем только результат функции mysql_query для запросов удаления, вставки return $this->result; } else { // Возвращаем свой объект if (!GL_CLASS_AUTOLOAD) { require_once classPath('Db_MySqlResult'); } return new Db_MySqlResult($this->result); } }
public function WriteLog($msg_text, $msg_type = 0, $user_quid = '', $logging = true) { if (!is_object($this->log)) { if (!GL_CLASS_AUTOLOAD) { require_once classPath('Log'); } $this->log = new Log($this->Db); } $this->log->Write($msg_type, $msg_text, $user_quid, $this->getBrowser($_SERVER['HTTP_USER_AGENT']), $logging); }