
Originally Posted by
torvista
The problem is not the database connection (that is working ok), but that PhpStorm cannot read/substitute the database constants in those queries for the constant definitions in
includes/database_tables.php with the DB_PREFIX.
So, this does not work:
define('TABLE_PRODUCTS', DB_PREFIX . 'products');
but this does work (clears the error)
define('TABLE_PRODUCTS', 'products');
web searches indicate this is not possible, I was just wondering if anyone had found a way to make it work without changing includes/database_tables.php.
PhpStorm 2021.1 now supports prefixed table names: https://blog.jetbrains.com/phpstorm/...ames_in_sql_wi
However I don't know exactly how to make it work.
I tried making the file .phpstorm.meta.php (the tables have no prefix):
Code:
namespace PHPSTORM_META {
override(
// Virtual function to indicate that all SQL
// injections will have the following replacement rules.
sql_injection_subst(),
map([
"DB_PREFIX" => "",
])
);
}
but the errors remain.
However in the article it says:
This works with concatenation as well. See the following example:
Code:
<?php
const DB_PREFIX = "mydatabase_";
$sql = "SELECT * FROM " . DB_PREFIX . 'table_name';
which means, I guess, that the previous .phpstorm.meta.php is not needed and you need to use const instead??
Bookmarks