could not translate host name "user=" to address: Unknown host?

CI框架+postgerSQL+nginx
现在又2个数据库:中心库center,公司库:n001
登录时使用中心库验证,可以正常登录。
在控制器A构造方法中,加载公司库:n001.
访问index方法,可以查询n001数据库中的数据。
但是在B方法中,使用同样的查询语句,则报错:

ERROR - 2017-11-08 15:12:12 --> Severity: Warning --> pg_pconnect(): Unable to connect to PostgreSQL server: could not translate host name "user=" to address: Unknown host D:\www\system\database\drivers\postgre\postgre_driver.php 153
ERROR - 2017-11-08 15:12:12 --> Unable to connect to the database
ERROR - 2017-11-08 15:12:12 --> userdb:{"dbdriver":"postgre","schema":"public","dsn":"host= user= dbname=","username":null,"password":null,"hostname":null,"database":null,"subdriver":null,"dbprefix":"","char_set":"utf8","dbcollat":"utf8_general_ci","encrypt":false,"swap_pre":"","port":"","pconnect":true,"conn_id":false,"result_id":false,"db_debug":false,"benchmark":0,"query_count":0,"bind_marker":"?","save_queries":true,"queries":[],"query_times":[],"data_cache":[],"trans_enabled":true,"trans_strict":true,"cache_on":false,"cachedir":"","cache_autodel":false,"CACHE":null,"autoinit":true,"stricton":false}
ERROR - 2017-11-08 15:12:12 --> Severity: Warning --> pg_pconnect(): Unable to connect to PostgreSQL server: could not translate host name "user=" to address: Unknown host D:\www\system\database\drivers\postgre\postgre_driver.php 153
ERROR - 2017-11-08 15:12:12 --> Unable to connect to the database
ERROR - 2017-11-08 15:12:12 --> Severity: Warning --> pg_last_error() expects parameter 1 to be resource, boolean given D:\www\system\database\drivers\postgre\postgre_driver.php 480
ERROR - 2017-11-08 15:12:12 --> Query error:  - Invalid query: select * from sys_column where grid_id='477F6FAD-B3A8-653E-B41C-3999DEB0F890' order by sort_code asc

最后一条提示错误的SQL语句是没问题的,可以出结果。

请问这样改如何解决?

阅读 6.5k
1 个回答

提示你没有配置数据库信息,提示没有连接到数据库

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题