1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

some adjustments

nils: please have a look at the @todo comment in mcp_queue.php


git-svn-id: file:///svn/phpbb/trunk@6002 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen
2006-06-02 13:26:27 +00:00
parent b087e60113
commit 7d264396df
13 changed files with 256 additions and 278 deletions

View File

@@ -225,17 +225,7 @@ class dbal
case 'SELECT':
case 'SELECT_DISTINCT';
if ($query == 'SELECT_DISTINCT')
{
$sql .= 'SELECT DISTINCT';
}
else
{
$sql .= 'SELECT';
}
$sql .= ' ' . $array['SELECT'];
$sql .= ' FROM ';
$sql = str_replace('_', ' ', $query) . ' ' . $array['SELECT'] . ' FROM ';
$table_array = array();
foreach ($array['FROM'] as $table_name => $alias)
@@ -270,6 +260,7 @@ class dbal
break;
}
return $sql;
}
@@ -316,7 +307,7 @@ class dbal
{
$this->sql_transaction('rollback');
}
if (strlen($message) > 1024)
{
// We need to define $msg_long_text here to circumvent text stripping.
@@ -487,8 +478,6 @@ class dbal
$this->_sql_report($mode, $query);
// $this->num_queries['cache']++;
break;
case 'record_fromcache':

View File

@@ -58,7 +58,7 @@ class dbal_firebird extends dbal
case 'begin':
$result = true;
$this->transaction = true;
break;
break;
case 'commit':
$result = @ibase_commit();
@@ -68,12 +68,12 @@ class dbal_firebird extends dbal
{
@ibase_rollback();
}
break;
break;
case 'rollback':
$result = @ibase_rollback();
$this->transaction = false;
break;
break;
default:
$result = true;
@@ -91,7 +91,6 @@ class dbal_firebird extends dbal
{
global $cache;
$this->last_query_text = $query;
$this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
@@ -103,7 +102,6 @@ class dbal_firebird extends dbal
$this->sql_error($query);
}
// TODO: have to debug the commit states in firebird
if (!$this->transaction)
{
@ibase_commit_ret();
@@ -132,19 +130,19 @@ class dbal_firebird extends dbal
* Build LIMIT query
*/
function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
if ($query != '')
{
if ($query != '')
{
$this->query_result = false;
$this->query_result = false;
$query = 'SELECT FIRST ' . $total . ((!empty($offset)) ? ' SKIP ' . $offset : '') . substr($query, 6);
return $this->sql_query($query, $cache_ttl);
}
else
{
return false;
}
}
else
{
return false;
}
}
/**
@@ -222,7 +220,7 @@ class dbal_firebird extends dbal
{
$this->sql_rowseek($rownum, $query_id);
}
$row = $this->sql_fetchrow($query_id);
return isset($row[$field]) ? $row[$field] : false;
}
@@ -241,16 +239,6 @@ class dbal_firebird extends dbal
$query_id = $this->query_result;
}
/*
$this->sql_freeresult($query_id);
$query_id = $this->sql_query($this->last_query_text);
if (!$query_id)
{
return false;
}
*/
// We do not fetch the row for rownum == 0 because then the next resultset would be the second row
for ($i = 0; $i < $rownum; $i++)
{
@@ -274,9 +262,9 @@ class dbal_firebird extends dbal
{
if ($this->query_result && preg_match('#^INSERT[\t\n ]+INTO[\t\n ]+([a-z0-9\_\-]+)#is', $this->last_query_text, $tablename))
{
$query = "SELECT GEN_ID(" . $tablename[1] . "_gen, 0) AS new_id
FROM RDB\$DATABASE";
if (!($temp_q_id = @ibase_query($this->db_connect_id, $query)))
$sql = "SELECT GEN_ID(" . $tablename[1] . "_gen, 0) AS new_id FROM RDB\$DATABASE";
if (!($temp_q_id = @ibase_query($this->db_connect_id, $sql)))
{
return false;
}
@@ -287,7 +275,7 @@ class dbal_firebird extends dbal
return ($temp_result) ? $temp_result->NEW_ID : false;
}
}
return false;
}

View File

@@ -65,7 +65,7 @@ class dbal_mssql extends dbal
case 'begin':
$result = @mssql_query('BEGIN TRANSACTION', $this->db_connect_id);
$this->transaction = true;
break;
break;
case 'commit':
$result = @mssql_query('commit', $this->db_connect_id);
@@ -75,12 +75,12 @@ class dbal_mssql extends dbal
{
@mssql_query('ROLLBACK', $this->db_connect_id);
}
break;
break;
case 'rollback':
$result = @mssql_query('ROLLBACK', $this->db_connect_id);
$this->transaction = false;
break;
break;
default:
$result = true;
@@ -146,10 +146,10 @@ class dbal_mssql extends dbal
* Build LIMIT query
*/
function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
if ($query != '')
{
if ($query != '')
{
$this->query_result = false;
$this->query_result = false;
// if $total is set to 0 we do not want to limit the number of rows
if ($total == 0)
@@ -170,11 +170,11 @@ class dbal_mssql extends dbal
}
return $this->sql_query($query, $cache_ttl);
}
else
{
return false;
}
}
else
{
return false;
}
}
/**
@@ -217,7 +217,7 @@ class dbal_mssql extends dbal
}
$row = @mssql_fetch_assoc($query_id);
// I hope i am able to remove this later... hopefully only a PHP or MSSQL bug
if ($row)
{
@@ -247,11 +247,11 @@ class dbal_mssql extends dbal
{
$this->sql_rowseek($rownum, $query_id);
}
$row = $this->sql_fetchrow($query_id);
return isset($row[$field]) ? $row[$field] : false;
}
return false;
}

View File

@@ -59,7 +59,7 @@ class dbal_mssql_odbc extends dbal
case 'begin':
$result = @odbc_autocommit($this->db_connect_id, false);
$this->transaction = true;
break;
break;
case 'commit':
$result = @odbc_commit($this->db_connect_id);
@@ -71,13 +71,13 @@ class dbal_mssql_odbc extends dbal
@odbc_rollback($this->db_connect_id);
@odbc_autocommit($this->db_connect_id, true);
}
break;
break;
case 'rollback':
$result = @odbc_rollback($this->db_connect_id);
@odbc_autocommit($this->db_connect_id, true);
$this->transaction = false;
break;
break;
default:
$result = true;
@@ -100,7 +100,6 @@ class dbal_mssql_odbc extends dbal
{
$this->sql_report('start', $query);
}
$this->last_query_text = $query;
$this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false;
@@ -145,10 +144,10 @@ class dbal_mssql_odbc extends dbal
* Build LIMIT query
*/
function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
if ($query != '')
{
if ($query != '')
{
$this->query_result = false;
$this->query_result = false;
// if $total is set to 0 we do not want to limit the number of rows
if ($total == 0)
@@ -168,12 +167,12 @@ class dbal_mssql_odbc extends dbal
$query = 'SELECT TOP ' . ($row_offset + $num_rows) . ' ' . substr($query, 6);
}
return $this->sql_query($query, $cache_ttl);
}
else
{
return false;
}
return $this->sql_query($query, $cache_ttl);
}
else
{
return false;
}
}
/**
@@ -214,7 +213,7 @@ class dbal_mssql_odbc extends dbal
{
return $cache->sql_fetchrow($query_id);
}
return ($query_id) ? @odbc_fetch_array($query_id) : false;
}
@@ -235,7 +234,7 @@ class dbal_mssql_odbc extends dbal
{
$this->sql_rowseek($rownum, $query_id);
}
$row = $this->sql_fetchrow($query_id);
return isset($row[$field]) ? $row[$field] : false;
}

View File

@@ -65,7 +65,7 @@ class dbal_mysql extends dbal
case 'begin':
$result = @mysql_query('BEGIN', $this->db_connect_id);
$this->transaction = true;
break;
break;
case 'commit':
$result = @mysql_query('COMMIT', $this->db_connect_id);
@@ -75,12 +75,12 @@ class dbal_mysql extends dbal
{
@mysql_query('ROLLBACK', $this->db_connect_id);
}
break;
break;
case 'rollback':
$result = @mysql_query('ROLLBACK', $this->db_connect_id);
$this->transaction = false;
break;
break;
default:
$result = true;
@@ -146,10 +146,10 @@ class dbal_mysql extends dbal
* Build LIMIT query
*/
function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
if ($query != '')
{
if ($query != '')
{
$this->query_result = false;
$this->query_result = false;
// if $total is set to 0 we do not want to limit the number of rows
if ($total == 0)
@@ -159,12 +159,12 @@ class dbal_mysql extends dbal
$query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total);
return $this->sql_query($query, $cache_ttl);
}
else
{
return false;
}
return $this->sql_query($query, $cache_ttl);
}
else
{
return false;
}
}
/**
@@ -302,9 +302,10 @@ class dbal_mysql extends dbal
$data = '(' . $data . ')';
break;
}
return $data;
}
/**
* return sql error array
* @private
@@ -318,7 +319,7 @@ class dbal_mysql extends dbal
'code' => @mysql_errno()
);
}
return array(
'message' => @mysql_error($this->db_connect_id),
'code' => @mysql_errno($this->db_connect_id)

View File

@@ -67,22 +67,22 @@ class dbal_mysql4 extends dbal
case 'begin':
$result = @mysql_query('BEGIN', $this->db_connect_id);
$this->transaction = true;
break;
break;
case 'commit':
$result = @mysql_query('COMMIT', $this->db_connect_id);
$this->transaction = false;
if (!$result)
{
@mysql_query('ROLLBACK', $this->db_connect_id);
}
break;
break;
case 'rollback':
$result = @mysql_query('ROLLBACK', $this->db_connect_id);
$this->transaction = false;
break;
break;
default:
$result = true;
@@ -148,10 +148,10 @@ class dbal_mysql4 extends dbal
* Build LIMIT query
*/
function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
if ($query != '')
{
if ($query != '')
{
$this->query_result = false;
$this->query_result = false;
// if $total is set to 0 we do not want to limit the number of rows
if ($total == 0)
@@ -162,12 +162,12 @@ class dbal_mysql4 extends dbal
$query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total);
return $this->sql_query($query, $cache_ttl);
}
else
{
return false;
}
return $this->sql_query($query, $cache_ttl);
}
else
{
return false;
}
}
/**
@@ -289,7 +289,7 @@ class dbal_mysql4 extends dbal
{
return @mysql_real_escape_string($msg);
}
return @mysql_real_escape_string($msg, $this->db_connect_id);
}
@@ -305,6 +305,7 @@ class dbal_mysql4 extends dbal
$data = '(' . $data . ')';
break;
}
return $data;
}
@@ -321,7 +322,7 @@ class dbal_mysql4 extends dbal
'code' => @mysql_errno()
);
}
return array(
'message' => @mysql_error($this->db_connect_id),
'code' => @mysql_errno($this->db_connect_id)

View File

@@ -67,7 +67,7 @@ class dbal_mysqli extends dbal
case 'begin':
$result = @mysqli_autocommit($this->db_connect_id, false);
$this->transaction = true;
break;
break;
case 'commit':
$result = @mysqli_commit($this->db_connect_id);
@@ -79,13 +79,13 @@ class dbal_mysqli extends dbal
@mysqli_rollback($this->db_connect_id);
@mysqli_autocommit($this->db_connect_id, true);
}
break;
break;
case 'rollback':
$result = @mysqli_rollback($this->db_connect_id);
@mysqli_autocommit($this->db_connect_id, true);
$this->transaction = false;
break;
break;
default:
$result = true;
@@ -146,10 +146,10 @@ class dbal_mysqli extends dbal
* Build LIMIT query
*/
function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
if ($query != '')
{
if ($query != '')
{
$this->query_result = false;
$this->query_result = false;
// if $total is set to 0 we do not want to limit the number of rows
if ($total == 0)
@@ -160,12 +160,12 @@ class dbal_mysqli extends dbal
$query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total);
return $this->sql_query($query, $cache_ttl);
}
else
{
return false;
}
return $this->sql_query($query, $cache_ttl);
}
else
{
return false;
}
}
/**
@@ -227,7 +227,7 @@ class dbal_mysqli extends dbal
{
$this->sql_rowseek($rownum, $query_id);
}
$row = $this->sql_fetchrow($query_id);
return isset($row[$field]) ? $row[$field] : false;
}
@@ -296,9 +296,10 @@ class dbal_mysqli extends dbal
$data = '(' . $data . ')';
break;
}
return $data;
}
/**
* return sql error array
* @private

View File

@@ -57,7 +57,7 @@ class dbal_oracle extends dbal
case 'begin':
$result = true;
$this->transaction = true;
break;
break;
case 'commit':
$result = @ocicommit($this->db_connect_id);
@@ -67,12 +67,12 @@ class dbal_oracle extends dbal
{
@ocirollback($this->db_connect_id);
}
break;
break;
case 'rollback':
$result = @ocirollback($this->db_connect_id);
$this->transaction = false;
break;
break;
default:
$result = true;
@@ -90,13 +90,12 @@ class dbal_oracle extends dbal
{
global $cache;
// EXPLAIN only in extra debug mode
if (defined('DEBUG_EXTRA'))
{
$this->sql_report('start', $query);
}
$this->last_query_text = $query;
$this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
@@ -128,7 +127,7 @@ class dbal_oracle extends dbal
$this->sql_transaction('commit');
}
}
if (defined('DEBUG_EXTRA'))
{
$this->sql_report('stop', $query);
@@ -161,19 +160,19 @@ class dbal_oracle extends dbal
* Build LIMIT query
*/
function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
if ($query != '')
{
if ($query != '')
{
$this->query_result = false;
$query = 'SELECT * FROM (SELECT /*+ FIRST_ROWS */ rownum AS xrownum, a.* FROM (' . $query . ') a WHERE rownum <= ' . ($offset + $total) . ') WHERE xrownum >= ' . $offset;
return $this->sql_query($query, $cache_ttl);
}
else
{
}
else
{
return false;
}
}
}
/**
@@ -220,7 +219,7 @@ class dbal_oracle extends dbal
{
return $cache->sql_fetchrow($query_id);
}
$row = array();
$result = @ocifetchinto($query_id, $row, OCI_ASSOC + OCI_RETURN_NULLS);
@@ -261,11 +260,11 @@ class dbal_oracle extends dbal
{
$this->sql_rowseek($rownum, $query_id);
}
$row = $this->sql_fetchrow($query_id);
return isset($row[$field]) ? $row[$field] : false;
}
return false;
}

View File

@@ -94,7 +94,7 @@ class dbal_postgres extends dbal
case 'begin':
$result = @pg_query($this->db_connect_id, 'BEGIN');
$this->transaction = true;
break;
break;
case 'commit':
$result = @pg_query($this->db_connect_id, 'COMMIT');
@@ -104,12 +104,12 @@ class dbal_postgres extends dbal
{
@pg_query($this->db_connect_id, 'ROLLBACK');
}
break;
break;
case 'rollback':
$result = @pg_query($this->db_connect_id, 'ROLLBACK');
$this->transaction = false;
break;
break;
default:
$result = true;
@@ -127,7 +127,6 @@ class dbal_postgres extends dbal
{
global $cache;
// EXPLAIN only in extra debug mode
if (defined('DEBUG_EXTRA'))
{
@@ -187,7 +186,7 @@ class dbal_postgres extends dbal
*/
function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
if ($query != '')
if ($query != '')
{
$this->query_result = false;
@@ -200,11 +199,11 @@ class dbal_postgres extends dbal
$query .= "\n LIMIT $total OFFSET $offset";
return $this->sql_query($query, $cache_ttl);
}
else
{
}
else
{
return false;
}
}
}
/**
@@ -266,7 +265,7 @@ class dbal_postgres extends dbal
{
$this->sql_rowseek($rownum, $query_id);
}
$row = $this->sql_fetchrow($query_id);
return isset($row[$field]) ? $row[$field] : false;
}
@@ -301,6 +300,7 @@ class dbal_postgres extends dbal
{
$query = "SELECT currval('" . $tablename[1] . "_seq') AS last_value";
$temp_q_id = @pg_query($this->db_connect_id, $query);
if (!$temp_q_id)
{
return false;
@@ -325,7 +325,7 @@ class dbal_postgres extends dbal
{
$query_id = $this->query_result;
}
if (isset($this->open_queries[(int) $query_id]))
{
unset($this->open_queries[(int) $query_id]);
@@ -337,10 +337,10 @@ class dbal_postgres extends dbal
/**
* Escape string used in sql query
* Note: Do not use for bytea values if we may use them at a later stage
*/
function sql_escape($msg)
{
// Do not use for bytea values
return @pg_escape_string($msg);
}

View File

@@ -61,7 +61,7 @@ class dbal_sqlite extends dbal
case 'begin':
$result = @sqlite_query('BEGIN', $this->db_connect_id);
$this->transaction = true;
break;
break;
case 'commit':
$result = @sqlite_query('COMMIT', $this->db_connect_id);
@@ -71,12 +71,12 @@ class dbal_sqlite extends dbal
{
@sqlite_query('ROLLBACK', $this->db_connect_id);
}
break;
break;
case 'rollback':
$result = @sqlite_query('ROLLBACK', $this->db_connect_id);
$this->transaction = false;
break;
break;
default:
$result = true;
@@ -94,7 +94,6 @@ class dbal_sqlite extends dbal
{
global $cache;
// EXPLAIN only in extra debug mode
if (defined('DEBUG_EXTRA'))
{
@@ -143,8 +142,8 @@ class dbal_sqlite extends dbal
* Build LIMIT query
*/
function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
if ($query != '')
{
if ($query != '')
{
$this->query_result = false;
@@ -157,11 +156,11 @@ class dbal_sqlite extends dbal
$query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total);
return $this->sql_query($query, $cache_ttl);
}
else
{
return false;
}
}
else
{
return false;
}
}
/**
@@ -225,7 +224,7 @@ class dbal_sqlite extends dbal
}
else
{
@sqlite_seek($query_id, $rownum);
$this->sql_rowseek($rownum, $query_id);
return @sqlite_column($query_id, $field);
}
}