[TYPO3-dev] pi_exec_query with addWhere returns only one element, what is wrong?

Matthias Stuebner news at stuebner.de
Mon Nov 27 18:05:39 CET 2006


Hello all,

in a simple kickstarter generated extension the listput is generated via

--------- code start -------------
$res = $this->pi_exec_query('tx_TestDB_main');

while($this->internal['currentRow'] =              
                         $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{
  $tRows[] = $this->pi_list_row($c);
  $c++;
}
--------- code end -------------

I want to show only certain IDs so I added a "addWhere" to pi_exec_query:

--------- code start -------------
// 1. implode $_POST['lit_uid'] into comma separated list
$comma_separated = implode(",", $_POST['lit_uid']);

// 2. Extend WHERE clause to return only selected items
$addUidList = "('".$comma_separated."')";
$addWhere = 'AND uid IN '.$addUidList;

// 3. Exec query
$res = $this->pi_exec_query('tx_TestDB_main',0,$addWhere);
--------- code end -------------

$addWhere correctly contains 'AND uid IN ("1,4,7")' and the exec_query
returns a valid result that is shown. What I wonder about is, that it shows
only the first result and not all anymore.

In the given example 'AND uid IN ("1,4,7")' the code:

--------- code start -------------
while($this->internal['currentRow'] = 
                        $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{
  $tRows[] = $this->pi_list_row($c);
  $c++;
}
--------- code end -------------

shows only the item 1, items 4 and 7 are not listed.

Is there anything special to take care about when I add an addWhere clause?

-- 
br Matthias




More information about the TYPO3-dev mailing list