"Unable to resolve column" because the table name is in a variable.
My code structure looks like this:
Even if its not run through the function to get the table name $tbl, the select query always shows "Unable to resolve column".
I know I can turn off inspections completely, what I'm wondering is if there is a way instruct phpstorm as to what the correct table name I'm interested in is.
If I type the actual name into the place of {$tbl} then the connection all works.
I see there is an old issue from 2011 that seems very similar to this topic. Any way to do this in 2019?
Please sign in to leave a comment.
Please map the schema for the file at File | Settings | Languages & Frameworks | SQL Resolution Scopes.
Each schema is defined by a module in its schema.php file. They look like this:
Is there a way to export the schema from the database to give it to phpstorm in a structure that it understands?
-- edit --
I exported just the schema from the database and added in to
LANGUAGES & FRAMEWORKS -> SQL RESOLUTION SCOPES
Then chose the resolution scope of the project to match the file, but the in the queries in the code still the same error shows.
Was hoping to find a more focused comment much like the @var or @method ones to help tell Phpstorm what the table should be so it could still inspect the rest of the statement.
Something like:
Maybe in the future JetBrains will add that or make PhpStorm clever enough to look at the variable 3 lines above.(c) Ben Rhys-Lewis
Dear JetBrain, can you please add the new feature, to add columns / tables resolving in cases when $table or $field are $variables:
1) to get value from /* @var */ annotation
2) to get value from alias in SQL query, like realColumnName and productsTable and realTableName in following query: