Boombatower's conversion doesn't seem to handle HAVING: SELECT uid FROM {userpoints} WHERE uid > 0 GROUP BY uid HAVING SUM(points) > %d
I wonder if this even works on a Postgres system, but that's not my issue.
How would this convert to DBTNG? Yes, I know I can still do a db_query (as I am currently doing), but I'd like to convert everything.
Nancy Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
The Group By is very easy with $query->grouBy('uid'); See http://drupal.org/node/310075#grouping for more on grouping.
The HAVING clause will need an expression though. See http://drupal.org/node/310075#expressions for more in expressions. It'll probably look something like:
$query->expression('HAVING SUM(points) > :placeholder', 'field_alias', array(':placeholder' => $argument));
Ms. Nancy Wichmann wrote:
Boombatower's conversion doesn't seem to handle HAVING: SELECT uid FROM {userpoints} WHERE uid > 0 GROUP BY uid HAVING SUM(points) > %d
I wonder if this even works on a Postgres system, but that's not my issue.
How would this convert to DBTNG? Yes, I know I can still do a db_query (as I am currently doing), but I'd like to convert everything.
Nancy Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
Note that if you do not need the dynamic facilities of the select builder, you should *not* convert a query over to it. The PHP overhead of the select builder is non-trivial compared to db_select(). Don't just blindly convert everything.
--Larry Garfield
On 10/26/2011 11:17 AM, Michael Prasuhn wrote:
The Group By is very easy with $query->grouBy('uid'); See http://drupal.org/node/310075#grouping for more on grouping.
The HAVING clause will need an expression though. See http://drupal.org/node/310075#expressions for more in expressions. It'll probably look something like:
$query->expression('HAVING SUM(points)> :placeholder', 'field_alias', array(':placeholder' => $argument));
Ms. Nancy Wichmann wrote:
Boombatower's conversion doesn't seem to handle HAVING: SELECT uid FROM {userpoints} WHERE uid> 0 GROUP BY uid HAVING SUM(points)> %d
I wonder if this even works on a Postgres system, but that's not my issue.
How would this convert to DBTNG? Yes, I know I can still do a db_query (as I am currently doing), but I'd like to convert everything.
Nancy Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
Now you tell me! I've been doing that for consistency.
Nancy Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
From: Larry Garfield
Note that if you do not need the dynamic facilities of the select builder, you should *not* convert a query over to it. The PHP overhead of the select builder is non-trivial compared to db_select(). Don't just blindly convert everything.