4

I have a query that works fine with one where clause however when I add AND it doesn't work, can someone please tell me what I'm doing wrong?

$args2 = array(':name' => $existingproductIDfield);
$args3 = array(':vid' => '6');
    $result2 = db_query('SELECT * FROM taxonomy_term_data WHERE name = :name', $args2 .'AND vid = :vid', $args3);

    if ($result2->rowCount() > 0) {
        foreach($result2 as $row) print_r($row);

    }
6

Parameter replacement is done all in one go, and you just need to provide a single associative array of args to db_query() for those replacements:

$args = array(':name' => $existingproductIDfield, ':vid' => 6);

$result2 = db_query('SELECT * FROM taxonomy_term_data WHERE name = :name AND vid = :vid', $args);
  • Clive you are the query master! Once again you helped me, thank you very much! – Brian Aug 31 '12 at 14:32
  • 2
    Hah "query master", I like that! Time to order some new business cards... – Clive Aug 31 '12 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.