In my project, I use MySQL and therefore configured PhpStorm to use the MySQL dialect to validate the query. I have a MySQL query that is built with plain SQL as well as using PHP variables.
Suppose I have the following code
$headline = 'Berlin';
$additional = (rand(1,5) > 2) ? ' AND t.public = 1' : '';
$query = "SELECT * FROM tours t WHERE t.headline = '". $headline . "'" . $additional .";";
If I print a request, it might look like this:
SELECT * FROM tours t WHERE t.headline = 'Berlin' AND t.public = 1;
or
SELECT * FROM tours t WHERE t.headline = 'Berlin';
Both queries are correct. However, PhpStorm shows an error in the next part.
>'"< . $additional .";";
with message
FOR, GROUP, HAVING, INTO, LIMIT, LOCK, ORDER, PROCEDURE or UNION are expected, '$ ('
The problem only occurs when I have a request element in phpvariable. How can I solve this problem?
source
share