Hey Michael,
$query = condition('ubr.rid', '@todo Set the appropriate argument.') Definitely my bad over here.
should have been $query->condition('ubr.rid', '@todo Set the appropriate argument.')
On Wed, Oct 12, 2011 at 1:06 PM, Michael Prasuhn mike@mikeyp.net wrote:
Dipen wrote:
http://upgrade.boombatower.com/tools/sql/inline
db_select('user_badges_roles', 'ubr') ->fields('ubr', array('rid', 'ubb')) ->join('user_badges_badges', 'ubb', 'ubb.bid = ubr.bid') ->condition('ubr.rid', '@todo Set the appropriate argument.') ->execute();
- the fields section is plainly incorrect as it won't select any fields
from user_badges_badges and has an erroneous field from user_badges_roles
- Join just returns the tables alias, not a select query object, so
it's not chainable.
Vaibhav Jain wrote:
You can use this query like this $query = db_select('user_badges_roles', 'ubr') ->fields('ubr', array('rid', 'ubb')) ->join('user_badges_badges', 'ubb', 'ubb.bid = ubr.bid');
$query = condition('ubr.rid', '@todo Set the appropriate argument.') ->execute();
Same problem as number 1 above, and what on earth is the condition function? I know of no procedural function in Drupal by that name.
Nancy, here's what you want:
$query = db_select('user_badges_roles', 'ubr'); $query->innerJoin('{user_badges_badges', 'ubb', 'ubb.bid = ubr.bid'); $result = $query->fields('ubr', 'rid') ->fields('ubb') ->condition('ubr.rid' $YOUR_ARGUMENT) ->execute();
There may be a more elegant way to get structure the query, but this will get you the results you're looking for.
-Mike
Michael Prasuhn mike@mikeyp.net
-- [ Drupal support list | http://lists.drupal.org/ ]