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

Steffen Kamper steffen at dislabs.de
Mon Nov 27 18:33:22 CET 2006


"Matthias Stuebner" <news at stuebner.de> schrieb im Newsbeitrag 
news:mailman.1.1164647137.27819.typo3-dev at lists.netfielders.de...
> 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
Hi - why don't you use a normal query ?
 $res=$GLOBALS['TYPO3_DB']->exec_SELECTquery($select_fields,$from_table,$where_clause,$groupBy='',$orderBy='',$limit='');vg  Steffen





More information about the TYPO3-dev mailing list