views:

33

answers:

1

I'm using node_load to load a node based on the value of one of its fields. If the field I'm testing against were uid for example, I would do it like this:

$n1 = node_load(array('uid' => $val));

but this field sub1 is nested in an array field_val[0][sub1]. I tried putting quotes around the whole thing, but it didn't work. I tried other small variations, but none worked.

$n1 = node_load(array('field_val[0][sub1]' => $val));

I'm wondering what's the correct syntax for doing this, if it can be done.

+5  A: 

The argument taken from node_load() is

  • An array following the format <table field> => <value>.
  • The node ID.

In the first case the array index is the name of a field found in the table node.

It's not possible to call node_load() as you reported.

kiamlaluno

related questions