20 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
33 include_once XOOPS_ROOT_PATH . '/class/database/database.php';
59 function connect($selectdb = TRUE)
61 static $db_charset_set;
63 if (!extension_loaded(
'mysql')) {
64 trigger_error(
'notrace:mysql extension not loaded', E_USER_ERROR);
68 $this->allowWebChanges = (
$_SERVER[
'REQUEST_METHOD'] !=
'GET');
77 $this->logger->addQuery(
'', $this->error(), $this->errno());
80 if ($selectdb != FALSE) {
82 $this->logger->addQuery(
'', $this->error(), $this->errno());
86 if (!isset($db_charset_set) && defined(
'XOOPS_DB_CHARSET') &&
XOOPS_DB_CHARSET) {
90 $this->queryF(
"SET SQL_BIG_SELECTS = 1");
103 function genId($sequence)
116 return @mysql_fetch_row(
$result);
126 return @mysql_fetch_assoc(
$result);
136 return @mysql_fetch_array(
$result, MYSQL_BOTH);
147 return @mysql_fetch_object(
$result);
155 function getInsertId()
157 return mysql_insert_id($this->conn);
168 return @mysql_num_rows(
$result);
176 function getAffectedRows()
178 return mysql_affected_rows($this->conn);
186 mysql_close($this->conn);
197 return mysql_free_result(
$result);
207 return @mysql_error();
217 return @mysql_errno();
226 function quoteString($str)
228 return $this->quote($str);
234 function quote($string)
236 return "'" . str_replace(
"\\\"",
'"', str_replace(
"\\"",
'"', mysql_real_escape_string($string, $this->conn))) .
"'";
256 $this->logger->startTime(
'query_time');
258 $this->logger->stopTime(
'query_time');
259 $query_time = $this->logger->dumpTime(
'query_time', TRUE);
261 $this->logger->addQuery(
$sql, NULL, NULL, $query_time);
264 $this->logger->addQuery(
$sql, $this->error(), $this->errno(), $query_time);
292 if (FALSE !== ($fp = fopen(
$file,
'r'))) {
293 include_once XOOPS_ROOT_PATH .
'/class/database/sqlutility.php';
294 $sql_queries = trim(fread($fp, filesize(
$file)));
296 foreach ($pieces as
$query) {
300 if ($prefixed_query != FALSE) {
301 $this->query($prefixed_query[0]);
318 return mysql_field_name(
$result, $offset);
330 return mysql_field_type(
$result, $offset);
341 return mysql_num_fields(
$result);
396 if (!$this->allowWebChanges && strtolower(substr(
$sql, 0, 6)) !=
'select') {
397 trigger_error(
'Database updates are not allowed during processing of a GET request', E_USER_WARNING);