Issue Bug Rejected

#25885DBAL fails with LIMIT clause

Sigfried Arnold 04/11/11, 13:17 updated 12/08/13, 11:44

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.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.