[TYPO3-dev] Problem with pi_list_browseresults()

Bernd Wilke xoonsji02 at sneakemail.com
Thu May 10 13:41:18 CEST 2007


On Thu, 03 May 2007 09:33:16 +0200, Brian Bendtsen wrote
with subject "[TYPO3-dev] Problem with pi_list_browseresults()":

> Hi
> 
> Im building an extension where I use the pi_list_makelist($res) and 
> pi_list_browseresults();
> 
> I have an sql that returns 2 records but the browseresults "thinks" that 
> there are 4.
> 
> I think its because I use group by.
> 
> This is my sql:
> 
> SELECT * FROM tx_ebbolig_afdeling INNER JOIN tx_ebbolig_lejemaal ON 
> tx_ebbolig_afdeling.uid = tx_ebbolig_lejemaal.afdelingid WHERE 
> tx_ebbolig_afdeling.organisation = 1 GROUP BY tx_ebbolig_afdeling.uid;
> 
> Im not sure what else to post here.
> 
> Any idea how to solve this?
> 
> /Brian Bendtsen

If you have something more complex than a simple "select ... from ... where
..." the functions pi_list_... of pi_base are difficult to handle.

as far as I remember first there is a request how many results it will be,
then there are the queries themself.

If you modify the select, mostly the first request stays unmodified (giving
to much results) and the later one is filtered to the less results, which
gives differences in displaying and paging.

as you use a join which isn't handled by pi_base you get these differences.
to correct it, you have to ignore the first 6 paramters of pi_exec_query
and build up your own querystring and use the 7th, last paramter.

be sure to use it on both calls to pi_exec_query()!!
they differ just in the second parameter:
first call:  pi_exec_query('',1,'','','','',$my_query);
second call: pi_exec_query('',0,'','','','',$my_query);

the first decides the number of results, and the second one prepares the
data.

Bernd
-- 
http://www.bernd-wilke.net




More information about the TYPO3-dev mailing list