1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-06 08:47:45 +02:00

ok, handled some bugs... the most important being validate_username (the variable passed to validate_data([...]array('username', [...])) and updating group listings while doing relevant group actions. Oh, and PM icons are working now. :o

git-svn-id: file:///svn/phpbb/trunk@6894 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen
2007-01-17 18:41:49 +00:00
parent 708113b790
commit a841fe70a8
42 changed files with 243 additions and 226 deletions

View File

@@ -114,6 +114,24 @@ class dbal
return $this->_sql_close();
}
/**
* Build LIMIT query
* Doing some validation here.
*/
function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
if (empty($query))
{
return false;
}
// Never use a negative total or offset
$total = ($total < 0) ? 0 : $total;
$offset = ($offset < 0) ? 0 : $offset;
return $this->_sql_query_limit($query, $total, $offset, $cache_ttl);
}
/**
* Fetch all rows
*/

View File

@@ -158,20 +158,13 @@ class dbal_firebird extends dbal
/**
* Build LIMIT query
*/
function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
if ($query != '')
{
$this->query_result = false;
$this->query_result = false;
$query = 'SELECT FIRST ' . $total . ((!empty($offset)) ? ' SKIP ' . $offset : '') . substr($query, 6);
$query = 'SELECT FIRST ' . $total . ((!empty($offset)) ? ' SKIP ' . $offset : '') . substr($query, 6);
return $this->sql_query($query, $cache_ttl);
}
else
{
return false;
}
return $this->sql_query($query, $cache_ttl);
}
/**

View File

@@ -159,40 +159,33 @@ class dbal_mssql extends dbal
/**
* Build LIMIT query
*/
function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
if ($query != '')
$this->query_result = false;
// Since TOP is only returning a set number of rows we won't need it if total is set to 0 (return all rows)
if ($total)
{
$this->query_result = false;
// Since TOP is only returning a set number of rows we won't need it if total is set to 0 (return all rows)
if ($total)
// We need to grab the total number of rows + the offset number of rows to get the correct result
if (strpos($query, 'SELECT DISTINCT') === 0)
{
// We need to grab the total number of rows + the offset number of rows to get the correct result
if (strpos($query, 'SELECT DISTINCT') === 0)
{
$query = 'SELECT DISTINCT TOP ' . ($total + $offset) . ' ' . substr($query, 15);
}
else
{
$query = 'SELECT TOP ' . ($total + $offset) . ' ' . substr($query, 6);
}
$query = 'SELECT DISTINCT TOP ' . ($total + $offset) . ' ' . substr($query, 15);
}
$result = $this->sql_query($query, $cache_ttl);
// Seek by $offset rows
if ($offset)
else
{
$this->sql_rowseek($offset, $result);
$query = 'SELECT TOP ' . ($total + $offset) . ' ' . substr($query, 6);
}
return $result;
}
else
$result = $this->sql_query($query, $cache_ttl);
// Seek by $offset rows
if ($offset)
{
return false;
$this->sql_rowseek($offset, $result);
}
return $result;
}
/**

View File

@@ -156,40 +156,33 @@ class dbal_mssql_odbc extends dbal
/**
* Build LIMIT query
*/
function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
if ($query != '')
$this->query_result = false;
// Since TOP is only returning a set number of rows we won't need it if total is set to 0 (return all rows)
if ($total)
{
$this->query_result = false;
// Since TOP is only returning a set number of rows we won't need it if total is set to 0 (return all rows)
if ($total)
// We need to grab the total number of rows + the offset number of rows to get the correct result
if (strpos($query, 'SELECT DISTINCT') === 0)
{
// We need to grab the total number of rows + the offset number of rows to get the correct result
if (strpos($query, 'SELECT DISTINCT') === 0)
{
$query = 'SELECT DISTINCT TOP ' . ($total + $offset) . ' ' . substr($query, 15);
}
else
{
$query = 'SELECT TOP ' . ($total + $offset) . ' ' . substr($query, 6);
}
$query = 'SELECT DISTINCT TOP ' . ($total + $offset) . ' ' . substr($query, 15);
}
$result = $this->sql_query($query, $cache_ttl);
// Seek by $offset rows
if ($offset)
else
{
$this->sql_rowseek($offset, $result);
$query = 'SELECT TOP ' . ($total + $offset) . ' ' . substr($query, 6);
}
return $result;
}
else
$result = $this->sql_query($query, $cache_ttl);
// Seek by $offset rows
if ($offset)
{
return false;
$this->sql_rowseek($offset, $result);
}
return $result;
}
/**

View File

@@ -163,27 +163,20 @@ class dbal_mysql extends dbal
/**
* Build LIMIT query
*/
function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
if ($query != '')
$this->query_result = false;
// if $total is set to 0 we do not want to limit the number of rows
if ($total == 0)
{
$this->query_result = false;
// if $total is set to 0 we do not want to limit the number of rows
if ($total == 0)
{
// Having a value of -1 was always a bug
$total = '18446744073709551615';
}
$query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total);
return $this->sql_query($query, $cache_ttl);
}
else
{
return false;
// Having a value of -1 was always a bug
$total = '18446744073709551615';
}
$query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total);
return $this->sql_query($query, $cache_ttl);
}
/**

View File

@@ -142,27 +142,20 @@ class dbal_mysqli extends dbal
/**
* Build LIMIT query
*/
function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
if ($query != '')
$this->query_result = false;
// if $total is set to 0 we do not want to limit the number of rows
if ($total == 0)
{
$this->query_result = false;
// if $total is set to 0 we do not want to limit the number of rows
if ($total == 0)
{
// MySQL 4.1+ no longer supports -1 in limit queries
$total = '18446744073709551615';
}
$query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total);
return $this->sql_query($query, $cache_ttl);
}
else
{
return false;
// MySQL 4.1+ no longer supports -1 in limit queries
$total = '18446744073709551615';
}
$query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total);
return $this->sql_query($query, $cache_ttl);
}
/**

View File

@@ -213,20 +213,13 @@ class dbal_oracle extends dbal
/**
* Build LIMIT query
*/
function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
if ($query != '')
{
$this->query_result = false;
$this->query_result = false;
$query = 'SELECT * FROM (SELECT /*+ FIRST_ROWS */ rownum AS xrownum, a.* FROM (' . $query . ') a WHERE rownum <= ' . ($offset + $total) . ') WHERE xrownum >= ' . $offset;
$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
{
return false;
}
return $this->sql_query($query, $cache_ttl);
}
/**

View File

@@ -192,26 +192,19 @@ class dbal_postgres extends dbal
/**
* Build LIMIT query
*/
function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
if ($query != '')
$this->query_result = false;
// if $total is set to 0 we do not want to limit the number of rows
if ($total == 0)
{
$this->query_result = false;
// if $total is set to 0 we do not want to limit the number of rows
if ($total == 0)
{
$total = -1;
}
$query .= "\n LIMIT $total OFFSET $offset";
return $this->sql_query($query, $cache_ttl);
}
else
{
return false;
$total = -1;
}
$query .= "\n LIMIT $total OFFSET $offset";
return $this->sql_query($query, $cache_ttl);
}
/**

View File

@@ -141,26 +141,19 @@ class dbal_sqlite extends dbal
/**
* Build LIMIT query
*/
function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
if ($query != '')
$this->query_result = false;
// if $total is set to 0 we do not want to limit the number of rows
if ($total == 0)
{
$this->query_result = false;
// if $total is set to 0 we do not want to limit the number of rows
if ($total == 0)
{
$total = -1;
}
$query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total);
return $this->sql_query($query, $cache_ttl);
}
else
{
return false;
$total = -1;
}
$query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total);
return $this->sql_query($query, $cache_ttl);
}
/**