1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 14:00:31 +02:00

made sql_rowseek consistent with the dbal methods as well as fixing sql_query_limit for mssql, especially if sql_query_limit($sql, 0, 0) is given...

git-svn-id: file:///svn/phpbb/trunk@6389 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen
2006-09-23 11:10:37 +00:00
parent 7542fabaa7
commit 6d08ef7b3a
13 changed files with 42 additions and 58 deletions

View File

@@ -172,30 +172,26 @@ class dbal_mssql extends dbal
{
$this->query_result = false;
// if $total is set to 0 we do not want to limit the number of rows
if ($total == 0)
// 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)
{
$total = -1;
}
$row_offset = ($total) ? $offset : '';
$num_rows = ($total) ? $total : $offset;
if (strpos($query, 'SELECT DISTINCT') === 0)
{
$query = 'SELECT DISTINCT TOP ' . ($row_offset + $num_rows) . ' ' . substr($query, 15);
}
else
{
$query = 'SELECT TOP ' . ($row_offset + $num_rows) . ' ' . substr($query, 6);
// 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);
}
}
$result = $this->sql_query($query, $cache_ttl);
// Seek by $row_offset rows
if ($row_offset)
// Seek by $offset rows
if ($offset)
{
$this->sql_rowseek($result, $row_offset);
$this->sql_rowseek($offset, $result);
}
return $result;
@@ -313,7 +309,7 @@ class dbal_mssql extends dbal
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_rowseek($query_id, $rownum);
return $cache->sql_rowseek($rownum, $query_id);
}
return ($query_id) ? @mssql_data_seek($query_id, $rownum) : false;