sql_build_query change proposal

General discussion of development ideas and the approaches taken in the 3.x branch of phpBB. The current feature release of phpBB 3 is 3.3/Proteus.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.3.x. If you need support for phpBB 3.3.x please visit the 3.3.x Support Forum on phpbb.com.

If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
Post Reply
sajaki
Registered User
Posts: 86
Joined: Mon Jun 21, 2010 8:28 pm

sql_build_query change proposal

Post by sajaki »

Concerning http://wiki.phpbb.com/display/DEV/Dbal.sql+build+query, i'd like to propose a change.

the 'FROM' key array should be structured inversely of what it is now.
so instead of :

Code: Select all

 'FROM'      => array(  
        BOOKMARKS_TABLE => 'b',  
        TOPICS_TABLE    => 't' 
   ),  
you write this :

Code: Select all

 'FROM'      => array(  
         'b' => BOOKMARKS_TABLE ,  
        't'  => TOPICS_TABLE   
   ),  
advantage : you can use a table multiple times in your select. this is necessary when writing a self-join query.
also, it adheres more to the "key-value" concept.

i stumbled on this problem while working on my mod here :
http://www.phpbb.com/community/viewtopi ... #p12861299

igorw
Registered User
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

Re: sql_build_query change proposal

Post by igorw »

While you are technically absolutely correct, I do not think it's wise to change/break APIs in this way. Extending the API may be an option, but you need to come up with a good solution ('FROM2' is it not). In your case I would simply suggest writing the query as plain SQL.

ToonArmy
Registered User
Posts: 335
Joined: Fri Mar 26, 2004 7:31 pm
Location: Bristol, UK
Contact:

Re: sql_build_query change proposal

Post by ToonArmy »

As a crude hack you could probably do

Code: Select all

'FROM' => array(
TOPICS_TABLE => 't1',
TOPICS_TABLE . ' ' => 't2',
)
 
Chris SmithBlogXMOOhlohArea51WikiNo support via PM/IM
Image

sajaki
Registered User
Posts: 86
Joined: Mon Jun 21, 2010 8:28 pm

Re: sql_build_query change proposal

Post by sajaki »

ToonArmy wrote:As a crude hack you could probably do

Code: Select all

'FROM' => array(
TOPICS_TABLE => 't1',
TOPICS_TABLE . ' ' => 't2',
)
 
if you debug that, the resulting sql will only have the second table in it, i.e. t2, and any selected value referring to t1 will cause an sql error.

Post Reply