New to PhpStorm: having problem with Drupal integration, "OJ Expected: got 'xxxxxx'"


I apologize if this is the wrong place for this question, but I've searched the forums/google/docs for the answer and can't figure it out. I'm running PhpStorm 7.0 with Drupal Integration (running Drupal 7).  I'm just trying to use db_query but I'm getting the above error on very simple code.  For example:

$result = db_query( "SELECT disease FROM {health} WHERE id = :id", array( ':id' => $id ) );

PhpStorm marks the higlighted part {health} as "OJ expected, got 'health'".  I don't understand what this error means.  Semantically, everything about this code is correct.  I have a made a successful connection to MySQL from PhpStorm.  A database exists within MySQL which has a table named "health".

Can someone point me in the right direction here?

Comment actions Permalink

So I figured it out.  PhpStorm doesn't like the following syntax:

db_query( "SELECT disease FROM {health}

it wants:

db_query( "SELECT disease FROM health

Comment actions Permalink

Hi there,

What SQL Dialect you have selected?

See comments here:

Comment actions Permalink

I'm using MySQL.

Comment actions Permalink

What will happen if you will NOT change SQL dialect to MySQL but set it back to Drupal SQL?

Comment actions Permalink

Hi thank you for your help.

"Drupal SQL" was never an option.  The options in the drop down menu are:

<SQL keywords>
Oracle SQL*Plus
SQL Server

Comment actions Permalink

As I understand this is from "Settings | SQL Dialects". What if you clear it -- when no specific dialect is selected there?

As I understand (sorry, never used Drupal myself,  not even in PhpStorm) "Drupal SQL" is some internal thing and when you  choose specific SQL Dialect it gets "lost/overriden".

Comment actions Permalink

There is no option for "Drupal SQL" even when you start a brand new drupal project.  It does not auto-default to "Drupal SQL" when you tell PhpStorm that you would like to start a new Drupal Project.

Comment actions Permalink

I've based my answers by having "Drupal SQL" term mentioned in that ticket without actually trying it myself first. Same as you I have not found it being mentioned anywhere in my test Drupal project now.

By default SQL Dialect is set to none (Keywords only) and that makes IDE to not to complain about that error, since it does not perform any SQL code validation (which is performed by Database support module and validates the code against actual dialect (MySQL in your case), in which "{table_name}" is not valid construction -- it validates whole command as is without any pre-processing (e.g. replacing {table_name} by proper table name etc)).

At the moment I may only suggest to set SQL Dialect back to it's original state (Keywords only) so no errors will be shown and watch for updates in that ticket:


Please sign in to leave a comment.