PHP and SQL strings with variables

Is there any way to get Intellij to recognize strings as SQL when they contain a variable?

For example:
$query = "select * from table where id = 0"; //highlights and is recognized as SQL

$query = "select * from table where id = $table_id"; //is not recognized as SQL

I hope this is the correct place to ask my question.

3 comments
Comment actions Permalink

Hello.

I presume, this is the known problem: http://youtrack.jetbrains.com/issue/WI-2450 (correct me if you mean something different). The issue is that language injection is initially created for Java, where there is no such things like "inlined" variables in string literals.

Welcome to vote and comment.

Regards,
Alexander.

0
Comment actions Permalink

Actually, in that case it at least appears to recognize the string as SQL, although invalid. In my case it doesn't even recognize that it's a SQL string, it's treated just like any other string. I suppose though, if it's going to end up showing as an error anyway, it really doesn't matter that much.

0
Comment actions Permalink

This may be different problem. How do you inject the SQL? In other words, why $query value should be an SQL in your code?

Thanks,
Alexander.

0

Please sign in to leave a comment.