Simetrical schreef:
On Wed, May 7, 2008 at 3:23 PM, Roan Kattouw
<roan.kattouw(a)home.nl> wrote:
They're far from unneeded.
Database::select() is broken in that it adds
the backticks wrongly, generating invalid SQL [1]. I'll poke dantman to
fix this, but in the meantime we should have a working API.
You know, every other place in the entire code base where we have
inner joins, we just use implicit joins with WHERE. So in other
words, don't use ON at all. Instead of SELECT * FROM page INNER JOIN
revision ON page_id=rev_page WHERE page_id=731, use SELECT * FROM
page, revision WHERE page_id=731 AND page_id=rev_page (don't ever try
either for arbitrary pages, BTW :)). The queries are totally
equivalent. There should be no reason to use any other syntax for
inner joins, although stylistically I do prefer ON clauses.
Unfortunately, this isn't about INNER JOINs (which I'm smart enough to
rewrite), but about LEFT JOINs, which are pretty much impossible to
construct cleanly right now. I would very much welcome support for LEFT
JOINs in the Database class, so I can port it to ApiQueryBase as well.
I can't patch your code, however, since as usual,
the API uses its own
syntax for database queries and non-API developers like me have no
idea how it works.
If you're interested, take a look at the ApiQueryBase class.
The basic
idea is that all ApiQuery* classes inherit helper functions from
ApiQueryBase which build the arrays Database::select() takes one element
at a time. This is done because many WHERE clauses and selected fields
have to be included or omitted dynamically (i.e. depending on the query
parameters).
Roan Kattouw (Catrope)