Score:1

Get raw SQL query from Drupal::entityTypeManager

cn flag

How can I fetch the raw sql version of the following statement?

             $t = \Drupal::entityTypeManager()
              ->getStorage('taxonomy_term')
              ->loadByProperties(['name' => $s, 'vid' => $v]);

Couldn't find anything suitable to try with EntityTypeManager. TIA.

4uk4 avatar
cn flag
@Lambic, I've removed my duplicate vote. Would you mind posting this as answer?
Score:5
ph flag

Glad this question was re-opened, converting my comment to an answer:

If you write it as an entity query then you can cast it to a string, like this:

$t = \Drupal::entityTypeManager()
  ->getStorage('taxonomy_term')
  ->getQuery()
  ->condition('vid', 'test')
  ->condition('name', 'test'); 
var_export((string) $t)
meen avatar
cn flag
Thanks for sharing the answer! I tried and I get different count of results if I use this piece of code. I guess some additional condition is checked in case of loadByProperties.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.