In my Drupal Query I need to recreate something likeexecute this SQL query using a dynamic query:queries.
WHERE (node_field_data.status = 1)
AND (node__field_document_places.entity_id IN (SELECT entity_id FROM node__field_document_places where field_document_places_target_id = 51673))
WHERE (node_field_data.status = 1)
AND (node__field_document_places.entity_id IN (SELECT entity_id FROM node__field_document_places where field_document_places_target_id = 51673))
In my code hereThis is the relevant part of my dynamic querycode I am building:using.
$connection = Database::getConnection();
$query = $connection->select('node_field_data', 'node_field_data');
$query->condition('node_field_data.status',1);
$query->condition('node__field_document_places.entity_id',[ -- Can I do this here somehow? -- ], "IN");
$connection = Database::getConnection();
$query = $connection->select('node_field_data', 'node_field_data');
$query->condition('node_field_data.status',1);
$query->condition('node__field_document_places.entity_id',[ -- Can I do this here somehow? -- ], "IN");
I could technically run a seperate Query before handseparate query and outputput the idsIDs in an array here. But I was hoping to keep a single DB call to help with speedavoid executing two different queries.
My Question is, isIs there a way to do this using dynamic queries, and is there even a performance benefit to do it this way.?