How to disable "unable to resolve column '[column]'" warning when double quoted string in SQL statement?

When I have an SQL query inside single quotes in a PHP file, if I use double quotes around text in the query, I get the warning:

"unable to resolve column '[column]'"

Here's example SQL:

SELECT "person" as objectType, .......

Where "person" is text and thus needs to be escaped with single or double quotes. The reason I don't like using single quotes to escape is that I have single quotes around the whole query, which means that I have to escape the single quotes like this:

SELECT \'person\' as objectType, .......

That's annoying because if I need to test a query in external software like Navicat, I have to go through and remove the backslashes.

How can I stop PhpStorm from generating this unnecessary warning?

2 comments
Comment actions Permalink

Hi there,

  • Alt+Enter while caret is standing on error position
  • Choose correct entry from appeared menu
  • Arrow right to see submenu
  • Choose the most appropriate action from there (e.g. Disable Inspection)


As I understand you have MySQL there.

The double quoted text is indeed treated as column name. At the moment there is no settings in IDE to treat them as ordinary strings:

0
Comment actions Permalink
The reason I don't like using single quotes to escape is that I have single quotes around the whole query, which means that I have to escape the single quotes like this:

How do you define your queries (PHP code please)?

I assume it's just an ordinary string, e.g.

$sql = 'SELECT bla FROM bla-bla';


If so -- try HEREDOC/NOWDOC (http://www.php.net/manual/en/language.types.string.php), e.g.

$sql = <<<SQL
SELECT bla FROM bla-bla
SQL;

0

Please sign in to leave a comment.