Search code examples
phpmysqlphpstorm

How can I add an acceptable operator to PhpStorm for MySQL?


Using PhpStorm with a MySQL connection, it looks like PhpStorm doesn't "accept" the != operator.

In a query, it colors the fields dark purple (for me) when I do something like:

SELECT table.id WHERE table.id = 2

In the above, PhpStorm colors id purple. It also gives me a list of hints after I type table.

However, if my query looks like this:

SELECT table.id WHERE table.id = 2 AND table.otherID != 4 AND table.otherID = 5

PhpStorm does not type hint or color anything after the != operator.

If, on the other hand, I use the <> operator, PhpStorm type hints and colors as normal.

So my question is, can I add != as an acceptable operator? OR, do I have a setting incorrect?

Edit: Disregard that it's not a PDO statement. I'm using PDO :-)


Solution

  • Looks like I found my answer in another question's answers, but that answer wasn't accepted nor upvoted (may not have been relevant to question). So I'm posting that answer to this one, in case someone runs into something similar:

    In phpStorm 9.0 on Ubuntu I had to change the Project SQL dialect

    File > Settings > Language & Frameworks > SQL Dialects > Click Project Directory & Click SQL Dialect and change it to MySQL

    After I did this, it accepted the "!=" operator and continued to type hint thereafter. I'm using PHPStorm v2016.1

    *Credit goes to user Timo Huovinen

    Link to question that helped me