简体   繁体   English

Codeigniter数据库连接错误和db_select

[英]Codeigniter database connections error and db_select

I'll try to be brief and to the point. 我会尽量简明扼要。

  1. I'm using Codeigniter 3.1.4. 我正在使用Codeigniter 3.1.4。 with HMVC 与HMVC
  2. Working perfectly on localhost with 'pconnect' = FALSE; 使用'pconnect' = FALSE;在localhost上完美地工作'pconnect' = FALSE;
  3. Problem at live server through shared hosting. 通过共享主机在实时服务器上出现问
  4. max_user_connections = 10 . max_user_connections = 10 Set by the Hosting company. 由托管公司设置。
  5. Also added mysql.allow_persistent = Off to php.ini file. mysql.allow_persistent = Off添加到php.ini文件中。
  6. Gives the error Message: mysqli::real_connect(): (42000/1203): User <user> already has more than 'max_user_connections' active connections Filename:mysqli/mysqli_driver.php Line Number: 201 给出错误Message: mysqli::real_connect(): (42000/1203): User <user> already has more than 'max_user_connections' active connections Filename:mysqli/mysqli_driver.php Line Number: 201
  7. Line 201 is calling mysqli::real_connect within db_connect function of mysqli_driver Line 201 mysqli::real_connect函数中调用mysqli::real_connect real_connect
  8. CI's official statement is "...CodeIgniter intelligently takes care of closing your database connections". CI的官方声明是“...... CodeIgniter智能地处理关闭数据库连接”。

With pconnect = FALSE; pconnect = FALSE; and CI's "intelligent" closing of database connections, I don't see what should be causing the problem. 和CI的“智能”关闭数据库连接,我看不出应该导致什么问题。

EDIT 编辑

  • Was previously loading database groups through $this->load->database('group', TRUE); 先前是通过$this->load->database('group', TRUE);加载数据库组$this->load->database('group', TRUE); in each model (only one such call per model). 在每个模型中(每个模型只有一个这样的调用)。
  • Tried resolving above error through autoloading 'database' library and setting $this->db->db_select('dbName'); 尝试通过自动加载“数据库”库并设置$this->db->db_select('dbName');解决上述错误$this->db->db_select('dbName'); in respective controllers+models but it's not always selecting the correct database when controller+model is loaded. 在各个控制器+模型中,但加载控制器+模型时并不总是选择正确的数据库。
  • Does anyone know how db->db_select() works? 有谁知道db->db_select()是如何工作的?

Any ideas would be great help. 任何想法都会有很大的帮助。 Thanks. 谢谢。

Check your database setting inside applications/config folder. 检查applications / config文件夹中的数据库设置。

Somewhere you had mentioned mysql and somewhere mysqli. 在某处您提到过mysql和mysqli。

Remember current version of CodeIgniter doesn't support mysql. 记住当前版本的CodeIgniter不支持mysql。

Hope it helps 希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM