PHPStorm warnings on placeholders in WordPress plugin queries PHPStorm warnings on placeholders in WordPress plugin queries wordpress wordpress

PHPStorm warnings on placeholders in WordPress plugin queries


This is now possible in PHPStorm 8, as explained by this post on the official PHPStorm blog:

Database Language Injection Configuration

To solve it:

  • Go to Tools > Databases
  • Make sure a regex matching the placeholders in question is in the list of custom parameters. By default, the list includes \%\w+, which will match %s, %d, etc.
  • Check the box labeled "Use in other language string literals"

PHPStorm will now correctly recognize placeholders like those used in WordPress.


Nope -- %d is not valid syntax from SQL point of view (ANY currently supported dialect). The WI-3672 and WI-2324 tickets are still valid.

But PhpStorm v8 now supports $var (if you could use it instead of % syntax) -- http://youtrack.jetbrains.com/issue/WI-2450


Since it's WordPress specific question, it's hard for me to give you any real suggestion (especially since I'm not using WordPress myself) excluding that one.

But generally speaking you could use native place holders supported by specific DB engine (check "Examples" section in http://php.net/manual/en/pdo.prepare.php):

  • unnamed ?
  • named :id

I just not sure if this can be applied to WordPress development.


P.S.Generic is the new Keywords only dialect -- fall back to that if using proper SQL dialect shows to many warnings/errors (that are not actual errors).