J
J
joger2014-09-19 13:12:15
PHP
joger, 2014-09-19 13:12:15

How to fix this error in PHPStorm 8?

There is a simple line in the project (PHP):

$stmt = $db->prepare("SELECT * FROM " . $table . " WHERE Value=?");

Today I updated PHPStorm and after FROM it began to show an error:
<coma join expression> expected, got ':'
Is this a bug or am I missing something? If a bug, then what is the name of this inspector to cut him down?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Mikhail Osher, 2014-09-19
@miraage

$stmt = $db->prepare(sprintf('SELECT * FROM %s WHERE Value=?', $table));

To my knowledge, sprintf is much faster than string concatenation/interpretation.
And, personally, in my opinion, much more readable.

N
Nikita Gusakov, 2014-09-19
@hell0w0rd

they added the sql parsing directly to the strings, as it used to be with html. Try to
insert $table into the string, you use " "

A
Alexander Vitkalov, 2015-02-18
@nechin

If you still need it, then in the settings I cleared SQL Dialect, and in Inspections -> SQL-> SQL dialect detection unchecked

D
Dmitriy, 2015-08-30
@kuaukutsu

PhpStorm lets us customize SQL parameters! From the settings under Tools | Databases, we can tell PhpStorm which tokens the SQL analyzer should recognize as being valid.
blog.jetbrains.com/phpstorm/2014/11/database-langu...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question