We use a class which extends Mysqli at work, and it adds another syntax for prepared statements, something like :
<?php
$req = MySQLiWrapperClass::getInstance()->prepare('
INSERT INTO
table
SET
field = :field_value:s
')
->bindNamedValue('field_value', 'stackOverflow')
->execute();
The class will then transform :field_value:s
to ?
before executing the query.
Problem is, when using MySQL SQL dialect in PhpStorm, this syntax will trigger an error because this syntax is not recognized.
Is there a way to declare a new SQL Dialect, in which I could add this specific syntax ?
You cannot add your own SQL Dialect just like that (that's not configurable via some GUI).
What I mean is: Yes, you can, but you have to code it as a plugin in Java, do the all stuff needed -- it will work.
The issue that you are having here has nothing to do with SQL Dialect -- you are not providing new keywords or actual query syntax (or stuff like that).
The issue in your code is in custom syntax for parameters (
:field_value:s
vs:field_value
).This can be resolved by specifying your own syntax at
Settings/Preferences | Tools | Database | User Parameters
::(\w+\:[d|i|s])
literals
at very leastImportant: order of the rules matters as well.
Here is what I did and how it works: