Skip to main content

Display raw SQL query of views programmatically in Drupal 8

How to display raw sql query of a  views in Drupal 8?

To see views SQL query, you can use hook_views_pre_execute(ViewExecutable $view)

function hook_views_pre_execute(ViewExecutable $view) {
  print_r($view->query->query()->__toString()); die();
}

Use __toString() with query to return raw SQL query.


Comments

Popular posts from this blog

Use Case Diagram for Online Book Store

Occurrences of each letter of alphabet in the text

Program to print a table indicating the no. of occurrences of each letter of alphabet in the text entered as command line arguments. #include<iostream> #include<string> using namespace std; int main(int argc, char *argv[]) { string str=""; static int alphabet[26]; int x; cout<<"\n\n Command-Line Argument\n"; for(int i=0;i<argc;i++) { cout<<"\n "<<argv[i]; str+=argv[i]; } for(int i=0;i<str.length();i++) { if(str[i]>='A' && str[i]<='Z') { x=((int)str[i])-65; alphabet[x]++; } else if(str[i]>='a' && str[i]<='z') { x=((int)str[i])-97; alphabet[x]++; } } //Displaying No. of occurrences of each alphabets in the command line argument cout<<"\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n Alphabet No. of Occurrences\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; for(int i=0;i<26;i++)...

How to Run SQL Command Line in Oracle 10g

Step 1: Goto start button  then program menu. Step 2:  Expand Oracle.                             Step 3: Select “ Run SQL Command Line”. Step 4: Now type in SQLPlus command prompt following commands: - a)       Type   connect b)       Enter username as “ System” c)       Then, Enter password of your Oracle 10g               Step 5: Now execute your SQL commands. e.g. : -