SQL and constants, any way to retain syntax highlighting?
Hi,
On the system I normally use the database tables are held in an array so I get queries like this:
$sql = "SELECT *
FROM {$jamroom_db['some_table']} ";
$rows = dbQuery($sql, 'NUMERIC');
but on a new system the table names are defined as constants, so a query looks like this:
$sql = "SELECT *
FROM ". SOME_TABLE .";
WHERE 1 ";
$rows = dbQuery($sql, 'NUMERIC');
In the first example PhpStorm recognizes that the $sql is a mysql query and highlights the syntax for mysql, but in the second, its all just treated as a normal string.
Is there any way to use constants in an SQL query so that PhpStorm can still highlight the syntax for me?
Thanks
请先登录再写评论。
Hi michael,
You are out of luck here: http://youtrack.jetbrains.com/issue/WI-534
Thanks Andriy,
I wasn't so hopeful, but its good to know for sure. Much appreciated.
Yea, we just developed a standard to convert constants to a variable like this before SQL use:
$iSQLUserID = _USERID;
$sSQL "SELECT u.first_name FROM users u WHERE u.id=$iSQLUserID";
Nice thinking. :)