How to "attach" a database to a PHP file/class?

I'm using PHPStorm 2019.1. I'm starting to use the database tools with it so I can get auto-complete of table and column names. I have two database connections: one for SQL Server and one for MySQL as the application access both. For some reason, only the tables and columns from the MySQL connection are auto-completing. I have some PHP classes which only reference the SQL Server connection but the auto-complete isn't working. Is there an easy way to get this to work? Thanks!

4 comments
Comment actions Permalink

Hi there,

Please check "Settings (Preferences on macOS) | Languages & Frameworks | SQL Resolution Scopes"

https://www.jetbrains.com/help/phpstorm/2019.1/settings-languages-sql-resolution-scopes.html

0
Comment actions Permalink

I had this already set up under Project Mapping. I had all of my MySQL databases selected and my one SQL Server database selected. I've specifically added one PHP class and set the resolution to only the SQL Server database and variations of dbo and all schemas to no avail.

0
Comment actions Permalink

Please attach a screenshot of that so we could look into details

0
Comment actions Permalink

I figured it out. It ended up being an issue where the SQL dialect wasn't specified for the file. I had set the project to use the MariaDB dialect. I added some scopes at the file level by going to Settings > Languages & Frameworks > SQL Dialects. This resolved the issue.

0

Please sign in to leave a comment.