mirror of
https://github.com/dg/dibi.git
synced 2025-08-05 13:47:33 +02:00
- implemented applyLimit() in PDO driver
This commit is contained in:
@@ -247,7 +247,7 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver
|
||||
*/
|
||||
public function applyLimit(&$sql, $limit, $offset)
|
||||
{
|
||||
// offset suppot is missing...
|
||||
// offset support is missing
|
||||
if ($limit >= 0) {
|
||||
$sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ')';
|
||||
}
|
||||
|
@@ -257,7 +257,7 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver
|
||||
*/
|
||||
public function applyLimit(&$sql, $limit, $offset)
|
||||
{
|
||||
// offset suppot is missing...
|
||||
// offset support is missing
|
||||
if ($limit >= 0) {
|
||||
$sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ')';
|
||||
}
|
||||
|
@@ -305,7 +305,36 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver
|
||||
*/
|
||||
public function applyLimit(&$sql, $limit, $offset)
|
||||
{
|
||||
throw new NotSupportedException('PDO does not support applying limit or offset.');
|
||||
if ($limit < 0 && $offset < 1) return;
|
||||
|
||||
switch ($this->connection->getAttribute(PDO::ATTR_DRIVER_NAME)) {
|
||||
case 'mysql':
|
||||
$sql .= ' LIMIT ' . ($limit < 0 ? '18446744073709551615' : (int) $limit)
|
||||
. ($offset > 0 ? ' OFFSET ' . (int) $offset : '');
|
||||
break;
|
||||
|
||||
case 'pgsql':
|
||||
if ($limit >= 0) $sql .= ' LIMIT ' . (int) $limit;
|
||||
if ($offset > 0) $sql .= ' OFFSET ' . (int) $offset;
|
||||
break;
|
||||
|
||||
case 'sqlite':
|
||||
case 'sqlite2':
|
||||
case 'oci':
|
||||
$sql .= ' LIMIT ' . $limit . ($offset > 0 ? ' OFFSET ' . (int) $offset : '');
|
||||
break;
|
||||
|
||||
case 'odbc':
|
||||
case 'mssql':
|
||||
if ($offset < 1) {
|
||||
$sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ')';
|
||||
break;
|
||||
}
|
||||
// intentionally break omitted
|
||||
|
||||
default:
|
||||
throw new NotSupportedException('PDO or driver does not support applying limit or offset.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -133,7 +133,6 @@ class DibiProfiler extends DibiObject implements IDibiProfiler
|
||||
header("X-Wf-dibi-1-1-d$num: |$s|\\"); // protocol-, structure-, plugin-, message-index
|
||||
}
|
||||
header("X-Wf-dibi-1-1-d$num: |$s|");
|
||||
header("X-Wf-dibi-Index: d$num");
|
||||
}
|
||||
|
||||
if ($this->file) {
|
||||
|
Reference in New Issue
Block a user