By TheOldGuy223 on
What is the proper query to return an array of nid's of nodes that have a node reference field referanceing node 50 (example node number).
What is the proper query to return an array of nid's of nodes that have a node reference field referanceing node 50 (example node number).
Comments
You could use the views
You could use the views module (if for no other reason to determine the query)
Well I need to determine the
Well I need to determine the query to run operations on each node, not to display them.
Are you saying that the views module will actually ouput the queary language that i need?
wow! I had the option turned
wow! I had the option turned off by default, but once you enable it it does indeed show it! Thanks that is a huge help!
here is the query and what
here is the query and what the beggining of the code im trying to write, I know I have the fetch field operation wrong, it was copied from another snippet I was using.
How can I alter this so that the variable $numbers_list contains an array of Node ID's that I can loop through using a foreach loop.
The queary was created in views and outputs the correct nodes in views, in this example instead of outputting the nodes in views i just want the node ids in an array so I can loop through them.
Hint:(Im pretty positive that the answer is in modifying the code
array(":title" => $title, ":type" => $type))->fetchField();I would use this
I would use this approach
Interesting, Ive never seen a
I assuming that I will be putting the foreach loop in the place where you put the comment, correct?
Interesting, Ive never seen a query written in that way, could you point me to the documentation that talks about it.
Thanks for the code also!
That comes from reading How
That comes from reading How to use EntityFieldQuery which is specific to entities. For more general queries there is db_select(). You can also read about the Database API
Great! was I correct how i
Great! was I correct how i utilized the foreach? Im currently trying to debug my code (not working but im sure its part of the code i didnt publish in this question)
In general it looks correct
In general it looks correct though I would not use
&$valuesince nid is just a value. You might trying adding right before your 'for' loopdrupal_set_message("Nids:<pre>" . print_r($nids, TRUE) . '</pre>');to make sure the query is returning something.