我正在使用ZendDb
数据库适配器,它无法带来所有调整SQL
。例如,如果我想做一个,REPLACE INTO
我就必须这样编码:
$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);
问题是PhpStorm告诉我,这%s
是SQL内部的错误。
当我尝试对其进行热修复时,Alt + Enter我没有选择禁止对此行进行检查。
我需要这样的东西:
/** @noinspection SqlInspection */
我在Google上搜索并找到了此页面,但是似乎没有任何选项可以帮助您。
有任何想法吗?
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.