Hi

I've recently moved from Drupal 5 to 6 and I'm having problems getting nids using nat_get_nids function.

In Drupal 5 I used this php pseudo-code:

    for certain terms I catch their tid {
        array_push( $tids, $taxonomy->tid );
    }
    $nids = array_keys (nat_get_nids( $tids, FALSE));

...and I ended with an array of nids of "parent" nodes wich I used to create some views.

Now, in Drupal 6 I'm using a very similar code:

    $tids = array_keys($terms); /*wich is different, but it's the same array:
    $nat = nat_get_nids($tids);
    print_r($nat);

...but something fail, the resulting array returned from nat_get_terms contains only one result. For example:

$tids = Array ([0] => 247 [1] => 252 [2] => 253)
$nat = Array ([301] => Ghosts'n goblins)

...wich correspond just to the first tid (247).

Is this a bug or is my fault?

Kind regards and thanks in advance.

Comments

NoRandom’s picture

I've found the bug is solved using the old db_query:

    /*$result = db_query("SELECT n.nid, t.name FROM {nat} n INNER JOIN {term_data} t USING (tid) WHERE n.tid IN (". db_placeholders($tids) .")", $tids);*/
    $result = db_query("SELECT n.nid, t.name FROM {nat} n INNER JOIN {term_data} t USING (tid) WHERE n.tid IN ($tids)");

...so, it seems there is some kind of error in the new query. I don't know anything about mysql queries, does anyone find the error?

markabur’s picture

this appears to be fixed in HEAD, see http://drupal.org/node/382270

NoRandom’s picture

Status: Active » Fixed

Thanks, markabur. You are right, this modification corrects the issue.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.