[development] Strange query problem
nan_wich at bellsouth.net
Thu Apr 8 18:13:05 UTC 2010
I have other queries with subqueries that work just fine.
Nancy E. Wichmann, PMP
From: T L <tloud365 at gmail.com>
To: development <development at drupal.org>
Sent: Thu, April 8, 2010 2:06:36 PM
Subject: Re: [development] Strange query problem
I think Randy is right, I just ran a quick test with and without db_rewrite_sql--it works without db_rewrite_sql. This makes sense as db_rewrite_sql is among other things a regex looking for SQL keywords ('from', 'where', etc) and looks pretty much incompatible w/ subqueries.
Sorry I don't have any ideas for a fix.
On Thu, Apr 8, 2010 at 1:39 PM, Randy Fay <randy at randyfay.com> wrote:
There may certainly be something going on with db_rewrite_sql(), so you'll probably have to find out what the actual query is when it gets sent to mysql. Stepping into db_query() is a great way to do this.
>On Thu, Apr 8, 2010 at 11:20 AM, Aaron Winborn <winborn at advomatic.com> wrote:
>Can you post your Drupal query? Hard to troubleshoot w/o the original code.
>>nan wich wrote:
>>I have the following query, which works fine in PhpMyAdmin, but Drupal upchucks on it. Why?
>>>SELECT nc.nid, n.title, n.created, nc.daycount AS views_today, nc.totalcount AS total_views,
>>> (SELECT COUNT(*) FROM comments c WHERE c.timestamp >= 1270699200 AND c.nid=nc.nid) AS comments_today,
>>> FROM node_counter nc
>>> INNER JOIN node n ON n.nid=nc.nid
>>> LEFT JOIN node_comment_statistics cs ON cs.nid=nc.nid
>>> WHERE nc.daycount > 0
>>> ORDER BY nc.daycount DESC
>>>Yes, in Drupal, I do put the brackets around the table names.
>>>The error message says there's a problem at " AS comments_today, cs.comment_count FROM...".
>>>Nancy E. Wichmann, PMP
>>>Sometimes the questions are complicated and the answers are simple. - Dr. Suess
>>Drupal Multimedia available in September!
>Drupal Development, troubleshooting, and debugging
>randy at randyfay.com
VP of Technology, Abroad101
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the development