* Jeremy Baron jeremy@tuxmachine.com [Wed, 26 Oct 2011 01:09:07 -0400]:
Hi,
On Wed, Oct 26, 2011 at 00:31, Dmitriy Sintsov questpc@rambler.ru wrote:
I am not native English speaker, sorry.
That's fine but maybe helpful to know so I can be extra careful that I don't confuse you. As a last resort I think there are some Russian speakers on this list that may be able to help.
From my experience of many years of communicating with western people
and Russians on the Internet, western people are much more helpful and willing to help and to cooperate. That is not politically correct but true. Open source and freeware community in western countries is much more advanced than here in Russia.
Should I do not use table aliases at all?
Aliases should be fine. (at least per the docs I found and reedy's example)
If they are fine, why my second converted query (last post in bug 31534) https://bugzilla.wikimedia.org/show_bug.cgi?id=31534 fails to execute on MySQL ?
[i'm guessing] The problem is that the code assumes that a lone string is a table name for just 1 table and that any other semantics (multiple tables or tables with aliases) will be encoded in data structures rather than need to be parsed out of strings.
In my second query I placed all table alieses into php array keys, as it was suggested by Sam.
$res = self::$db->select( array( 'qu' => 'qp_users', 'qup' => 'qp_users_polls' ), array( 'qup.uid AS uid', 'name AS username', 'short_interpretation', 'long_interpretation', 'structured_interpretation' ), /* WHERE */ 'pid = ' . intval( $this->pid ), __METHOD__, array( 'OFFSET' => $offset, 'LIMIT' => $limit ), /* JOIN */ array( 'qu' => array( 'INNER JOIN', 'qup.uid = qu.uid' ) ) );
Why does it fail?
Anyway, could you just try this code and tell us what happens?
function getIntervalResults( $offset, $limit ) { $result = array(); $db = wfGetDB( DB_SLAVE ); $res = $db->select( array( 'qup' => 'qp_users_polls', 'qu' => 'qp_users' ), array( 'qu.uid as uid', 'name as username', 'count(pid) as pidcount' ), 'qu.uid=qup.uid', __METHOD__, array( 'GROUP BY' => 'qup.uid', 'ORDER BY' => $this->order_by, 'OFFSET' => $offset, 'LIMIT' => $limit ) ); foreach( $res as $row ) { $result[] = $row; } return $result; }
Thanks, Jeremy
Surely, I can. However my far goal is to make the whole extension compatible to non-MySQL DBMS, I guess this query will probably work, but I have another queries, like that second one with INNER JOIN. Maybe I should get rid of table aliases, the simpliest way. Dmitriy