14

I am using PhpStorm 2016.1.2 and have been comfortably using PhpStorm for a couple of years. I have my Storm set up with the Database connection and displaying the MySQL database that my PHP pages connect to. The SQL is usually written within the PHP page in custom functions via a database connection class.

An example code chunk:

$checkData = $dataBaseSecure->getSelect(
"SELECT check_login.fail_id, UNIX_TIMESTAMP(check_login.last_action) AS timer
FROM check_login WHERE check_login.ip_addr = ? AND check_login.check_drop = ? ",
 $data, TRUE);  

Don't worry about the database PHP wrapper, this style and layout of SQL in PHP has been around on my work for a couple of years, in PhpStorm and works completely and accurately on the server and on all testings.

As Of Yesterday (17th June 2016)

I don't know what's changed but suddenly PhpStorm is now telling me, on all my SQL strings, across all my Projects:

Unable to resolve symbol '<table name>'

or

Unable to resolve column '<column name>'

And also (due to this) PhpStorm no longer carries out any auto-complete or organisation functions as I work on my SQL code.

Solutions I've tried

  • I have already tried to invalidate and revalidate my caches based on this answer to a similar question. But that hasn't helped.

  • I have very carefully explored my settings but the PhpStorm Database tab successfully connects to the database, and as far as I'm aware I made no changes to cause this change in behaviour.

  • I have looked over the various (and many) settings in PhpStorm preferences but seen nothing that has shone any light on this issue, or the changes I have tweaked have not resolved it.

  • I have found this answer but this does not seem to apply as my table names are not variables. I have also found this post, which while dated 2014 shows a similar issue but not a suitable solution.

    • I only have one database connection in most projects, but the number of databases doesn't seem to effect if this issue occurs.
  • Fully escaping SQL queries with appropriate backticks around named entities does not resolve the issue.

  • I have correctly configured my SQL dialect to the correct MySQL.

  • Reading related posts I'm found on Stack Overflow has provided no useful information.


I have no plugins in PhpStorm that relate to this issue or PHP/MySQL interaction.

If you have any ideas how to resolve this please tell me. If you have specific preferences you'd like me to check please let me know and I can add them into the question, (there are so many preferences in PhpStorm I won't post them all here right now, as I'm sure most are not related to this issue).

The Key is that this system was working perfectly two days ago!!!

9
  • 1) Anything interesting in the idea.log (Help | Show Log in...)? 2) Try with ALL non-bundled plugins disabled 3) Exit PhpStorm; go to .idea subfolder for this project (this project settings) and delete dataSources.ids file; re-open project in PhpStorm and re-sync DB -- any better?
    – LazyOne
    Jun 18, 2016 at 13:56
  • 1) I had a look but nothing shone out, there are a few connection returns of -1 but no errors in the IDE. I have a bug report here: youtrack.jetbrains.com/issue/WI-32197 which contains a idea.log (different project, same issues). 2) tried that, no change. 3) This may have worked, I deleted the db connection details and rebuilt them from scratch and along with deleting the .ids file this seems to have fixed it, however two points: a) the database tab in PhpStorm now is working (circle icon) constantly, and b) Seems odd I suddenly need to do this for every project.
    – Martin
    Jun 18, 2016 at 14:18
  • If you have any clues as to the constent background work indicator on the database tab (how to work out what it's actually (trying) to do? that would be great. If you could add your point 3 as an answer I think that's a solution (along with possibly re-establishing the db connection from scratch). Although I'm still confused how this came about, maybe my server people did some update or something (I'm awaiting a reply email from them) @LazyOne
    – Martin
    Jun 18, 2016 at 14:27
  • What do you mean by "working constantly" ? Any screenshots or better small screencast? It seems to work OK here for me (local test project with local MySQL connection though). I may suggest checking for other tickets here as well: youtrack.jetbrains.com/issues/DBE . So far I have no idea at all as to why it have suddenly happened to all of you projects (as per your words) -- for me it has to be some IDE-wide change (e.g. plugin update .. or some other global logic/setting). Do you do you IDE-wide config backed up regularly by any chance?
    – LazyOne
    Jun 18, 2016 at 15:12
  • As to "busy indicator" -- maybe youtrack.jetbrains.com/issue/IDEA-148285 . Could also be your connection settings (e.g. from what I see from the log it is connecting to DB via SSH connection .. or wrong username/password?). In general (as experiment) -- close IDE; backup .idea subfolder for that project and delete it; open IDE and point to that project root folder -- IDE will create new project from those sources; reconfigure your project (at least the DB related part) and see how it will go. If it all works -- see what possible diff it has to your backed up copy.
    – LazyOne
    Jun 18, 2016 at 15:15

2 Answers 2

8

Please try re-synchronizing your DB schemas -- just in case if it somehow got corrupted or invalid.

If it did not give any visual results -- try more radical version of it:

  • close IDE
  • open .idea subfolder for this project (the place where this project settings are stored)
  • delete dataSources.ids file
  • re-open project in IDE
  • re-sync DB structure / re-create DB connection from scratch.
2
  • 1
    Resyncing the schemas did not work however deleting the .ids and then establishing a new Datasource (with the same details) did work.
    – Martin
    Jun 18, 2016 at 15:45
  • Tnx. For me it worked with 2017.1.4 as well - I deleted the dataSources.ids, reopened - didn't work. Then I duplicated the existing connection to DB and removed the old one - that fixed it. (note that when removing old connection, you're also lose any locally cached SQL commands that you used in sql console)
    – userfuser
    Jun 12, 2017 at 8:54
3

None of the above worked for me - what eventually did was...

Selecting a portion of the SQL string that would run and then right clicking and selecting "Execute" and selecting the schema.

For some reason that allowed PHPStorm (more like light drizzle) to figure out what it should be looking at.

2
  • 1
    The "Execute" implies that PHPStorm did sort of recognise it anyway, but hadn't formatted/displayed accordingly.
    – Martin
    Sep 17, 2021 at 10:35
  • 1
    The "cannot recognize table xyz" means PHPStorm recognized the string as SQL but could not match it to the schema. The issue was not whether it realised it was a SQL statement, but why it could not match it to the connected schema. And this is NOT a solution, this is a hack. WHY did it not work properly in the first place?
    – LordWabbit
    Sep 17, 2021 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.