Skip to main content
Tweeted twitter.com/StackDrupal/status/929019067285037056
removed "Drupal" from the title; removed tags from the title
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

Drupal 8 , get Get pure SQL from Drupal::entityQuery

Given the following examplecode, how can I print the SQL that is generated?

$bundle='my_bundle_type';
$query = \Drupal::entityQuery('node');
$query->condition('status', 1);
$query->condition('type', $bundle);
$entity_ids = $query->execute();

How can I print the SQL that is generated ?

What I have tried:

  • __toString() -__toString() doesn't work; dpq($query)work
  • doesn't work ,dpq($query) throws an error;error

Regards,

Oleg

Drupal 8 , get pure SQL from Drupal::entityQuery

Given the following example

$bundle='my_bundle_type';
$query = \Drupal::entityQuery('node');
$query->condition('status', 1);
$query->condition('type', $bundle);
$entity_ids = $query->execute();

How can I print the SQL that is generated ?

What I have tried:

  • __toString() - doesn't work; dpq($query)
  • doesn't work , throws an error;

Regards,

Oleg

Get pure SQL from Drupal::entityQuery

Given the following code, how can I print the SQL that is generated?

$bundle='my_bundle_type';
$query = \Drupal::entityQuery('node');
$query->condition('status', 1);
$query->condition('type', $bundle);
$entity_ids = $query->execute();

What I have tried:

  • __toString() doesn't work
  • dpq($query) throws an error
Source Link
Oleg Videnov
  • 1.8k
  • 2
  • 15
  • 26

Drupal 8 , get pure SQL from Drupal::entityQuery

Given the following example

$bundle='my_bundle_type';
$query = \Drupal::entityQuery('node');
$query->condition('status', 1);
$query->condition('type', $bundle);
$entity_ids = $query->execute();

How can I print the SQL that is generated ?

What I have tried:

  • __toString() - doesn't work; dpq($query)
  • doesn't work , throws an error;

Regards,

Oleg