0

I can't seem to figure out, are you not allowed to chain db_select methods?

$nid = db_select("node", "n")
            ->fields("n", array("nid"))
            ->condition("f.entity_type", "node", "=")
            ->condition("f.deleted", 0, "=")
            ->condition("f.field_products_product_id", $entity->product_id, "=")
            ->addTag("node_access")
            ->join(
                "field_data_field_products",
                "f",
                "f.entity_id = n.nid"
            )
            ->execute();

I have the above, and it just won't work it keeps erroring on the join. Basically I want to do

SELECT nid FROM node JOIN field_data_field_products ON entity_id = nid WHERE ...

1 Answer 1

4

This is answered in this other question:

How to perform join with multiple columns using db_select?

Calls to SelectQuery::join() (like-wise SelectQuery::leftJoin(), SelectQuery::innerJoin(), and SelectQuery::addJoin()) chain-able because those methods don't return a SelectQuery object, but the actual alias used for the join.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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