Actions
Bug #25885
closedDBAL fails with LIMIT clause
Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2011-04-11
Due date:
% Done:
0%
Estimated time:
TYPO3 Version:
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:
Description
This piece of code ignores the LIMIT optimization:
$query = $GLOBALS['TYPO3_DB']->SELECTquery( "uid", "pages", "uid IN(" . implode(',', $arr) . ") AND doktype = 1", "", "", "5" ); unset($arr); $res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, $query); while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $arr[] = $row['uid']; }
Resulting SQL-String ($query) is:
SELECT uid FROM pages WHERE uid IN(8,9,10,16,29,30,31,32,33) AND doktype = 1 LIMIT 5
It should return ($arr should contain them) 5 datasets with no specific order - but it returns all.
If the statement is changed (added a catalog-prefix to the table) it works:
SELECT uid FROM t3_sandbox.pages WHERE uid IN(8,9,10,16,29,30,31,32,33) AND doktype = 1 LIMIT 5
I have not figured out why its happening but it can be reproduced on multiple servers and in TYPO3 4.4 and 4.5 enviroments - i have not tested any other DB engine besides MySQL though.
Currently i use a very dirty workarond with array_splice() to LIMIT the entries in the Array, but this won't be a solution for bigger amouts of data.
Actions