PhpStorm无法解析多个数据库连接的列 [英] PhpStorm unable to resolve column for multiple database connections

查看:383
本文介绍了PhpStorm无法解析多个数据库连接的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只使用PhpStorm一个星期左右,到目前为止,我的所有SQL查询在建立数据库连接后都可以正常工作,没有错误.当前代码实际上使用了第二个数据库(一个用于用户,另一个用于特定产品),所以我也在数据库选项卡中添加了该连接,但是它仍然给我一个无法解析列"警告.

I have only been using PhpStorm a week or so, so far all my SQL queries have been working fine with no errors after setting up the database connection. This current code actually uses a second database (one is for users the other for the specific product) so I added that connection in the database tab too but its still giving me a 'unable to resolve column' warning.

有没有办法查看其查看的数据库?它可以与多个数据库一起使用吗?还是我做错了其他事情?

Is there a way to see what database its looking at? Will it work with multiple databases? Or have I done something else wrong?

以下错误:

$this->db->setSQL("SELECT T1.*, trunc(sysdate) - trunc(DATE_CHANGED) EXPIRES FROM " . $this->tableName . " T1 WHERE lower(" . $this->primaryKey . ")=lower(:id)")

这也是我的数据库设置窗口的外观,就像有些人遇到参数模式问题导致此错误的情况一样,但我很确定这不是这里的问题:

Also here is what my database settings window looks like as seen some people having problems with parameter patterns causing this error but I'm fairly sure that is not the issue here:

使用PhpStorm 10.0.3

Using PhpStorm 10.0.3

推荐答案

因此,简短的答案是,即使表名设置在上面的变量中,它也无法将表名作为变量读取.我以为PhpStorm可以解决这个问题.消除错误的唯一方法是完全关闭SQL检查(显然不理想,因为我在整个项目中都使用它),或者仅使用doc注释暂时禁用此语句:

So the short answer is that it cant read the table name as a variable even though its set in a variable above. I thought PhpStorm could work that out. The only way to remove the error would be to either completely turn off SQL inspections (obviously not ideal as I use it throughout my project) or to temporarily disable it for this statement only using the doc comment:

/** @noinspection SqlResolve */

希望找到更集中的注释,就像@var或@method一样,以帮助告诉Phpstorm该表应该是什么,以便它仍然可以检查该语句的其余部分.就像是: /** @var $this->tableName TABLE_IM_USING */ 也许将来JetBrains会添加它,或者使PhpStorm足够聪明以查看上面的3行变量.

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: /** @var $this->tableName TABLE_IM_USING */ Maybe in the future JetBrains will add that or make PhpStorm clever enough to look at the variable 3 lines above.

这篇关于PhpStorm无法解析多个数据库连接的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆