I am using the ZendDb
database adapter which doesn't bring all the tweaks SQL
can do. For example if I want to do a REPLACE INTO
I would have to code it like this:
$SQL = sprintf('REPLACE INTO %s (id, NAME, cache_id, compile_id, content) VALUES (%s, %s, %s, %s, %s)' %
array(self::TABLE_NAME, $id, $name, $cache_id, $compile_id));
$this->_zdb->query($SQL);
The problem is that PhpStorm tells me that the %s
is an error inside the SQL.
When I try hotfixing it with Alt + Enter I don't get the option to suppress the inspection for this line.
I' need something like this:
/** @noinspection SqlInspection */
I googled and found this page but nothing of the options seemed to help.
Any ideas?
Add \%\w+
pattern to Settings/Preferences | Tools | Database | User Parameters
-- it will tell IDE to treat such %s
as dynamic/external part of the code instead of actual SQL.
For example:
P.S. One day such pattern will be provided by default in PhpStorm.
https://youtrack.jetbrains.com/issue/WI-39271 -- watch this ticket (star/vote/comment) to get notified on any progress.
If you need an actual suppression .. then the most effective way is to treat the string as Plain Text instead of autodetected SQL.
For this, just place /** @lang text*/
just before the string, e.g.
$sql = /** @lang text*/'REPLACE INTO %s (id, NAME, cache_id, compile_id, content) VALUES (%s, %s, %s, %s, %s)';
NOTE: may not work if you are concatenating such string or perform other manipulations in place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With