Closed (fixed)
Project:
Drupal core
Version:
7.0-rc4
Component:
field system
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
1 Apr 2011 at 07:51 UTC
Updated:
1 Apr 2011 at 17:58 UTC
Greetings!
I need a push to get me going on learning db_select function.
I am trying to get the results of the node table, joined with field_mfield_1 and field_mfield_2 where uid = 1.
Problem is that I am stuck figuring out how to do joins in the new D7 structure.
I have this, modified from a block tutorial:
<?php
$query = db_select('node', 'n')
->fields('n', array('nid', 'title', 'created'))
->execute();
?>How do I do a join on this with field revisions set to current?
Thank you!
Comments
Comment #1
angelg33k commentedYou can do it i several steps, to get the right order in the query. Here is an example that selects the title from the node table and the body text from the field_data_body table.
The result set can then be treated like an array of objects, for example:
Comment #2
damien tournoud commentedIf you want to query for entities and field, use the EntityFieldQuery. DatabaseSelect is not the proper interface for doing this type of queries.
See http://api.drupal.org/api/drupal/includes--entity.inc/class/EntityFieldQ...
Comment #3
farald commentedThank you for replies!
I grinded a lot on this problem, and therefore learned a lot, but ultimately I went for another solution.
There are a lot of fields so..
..will do, and then use cache to store analyzed data for a period of time.
Thanks again!
Comment #4
farald commentedClosing up.