Codeigniter Too many connection __construct() - php

I am using CI 3.X. Now in my app I using multiple database. Now my hosting server allows max 100 connections, So my app gets down.
In my database configurations I have kept PCONNECT to FALSE .
Now My Structure is as follow:
I have a base controller MY_Controller which extends to CI_Controller.
Then I have a Customer_Controller which extends to MY_Controller.
In Customer_Controller I load my secondary database. And this Customer_Controller lives in libraries folder.
All my other controller extend to this controller.
So where Am I going wrong ? Why does my MySQL sever gets this error ???
the error i get it:
A PHP Error was encountered
Severity: Warning
Message: mysqli::real_connect(): (HY000/1040): Too many connections
Filename: mysqli/mysqli_driver.php
Line Number: 202
Backtrace:
File: /application/core/MY_Controller.php Line: 7 Function:
__construct
File: /application/libraries/Admin_Controller.php Line: 7 Function:
__construct
File: /application/controllers/admin/Dashboard.php Line: 16 Function:
__construct
File: index.php Line: 315 Function: require_once

You will need to increase the value of max_connections in your MySQL configuration file. Possible location for the file is: /etc/my.cnf.
On the file increase the value of max_connections system variable:
[mysqld]
set-variable=max_connections=500
Alternatively, you can also turn off persistent connection from MySQL.
[MySQL]
; Allow or prevent persistent links.
mysql.allow_persistent=Off

Related

Can't get the default controller of codeigniter to work in IIS

I am trying to host a codeigniter project on IIS Server but I can't get even the default controller to show instead what I receive is this below
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_URI::$config is deprecated
Filename: core/URI.php
Line Number: 101
Backtrace:
File: C:\inetpub\wwwroot\app\index.php
Line: 315
Function: require_once
I have web.config file, HTTP mappings, ISAPI, URL rewrite module and FastCGI all set but still the problem persist.
I will be very grateful if you guys can help me, am stranded.

How to load ion auth model in codeigniter HMVC

I am using the ion auth library for the CodeIgniter HMVC, I have copied all files from ion auth library to main CodeIgniter files but the controller, model, and views files copy to module directory Now it's showing me this error.
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Auth::$ion_auth_model
Filename: libraries/Ion_auth.php
Line Number: 122
Backtrace:
File: /opt/lampp/htdocs/CI_Hmvc/application/libraries/Ion_auth.php
Line: 122 Function: _error_handler
File: /opt/lampp/htdocs/CI_Hmvc/application/libraries/Ion_auth.php
Line: 70 Function: __get
File: /opt/lampp/htdocs/CI_Hmvc/application/third_party/MX/Loader.php
Line: 173 Function: _ci_load_library
File: /opt/lampp/htdocs/CI_Hmvc/application/third_party/MX/Loader.php
Line: 192 Function: library
File: /opt/lampp/htdocs/CI_Hmvc/application/third_party/MX/Loader.php
Line: 153 Function: libraries
File:
/opt/lampp/htdocs/CI_Hmvc/application/modules/home/controllers/Auth.php
Line: 9 Function: library
File: /opt/lampp/htdocs/CI_Hmvc/index.php Line: 315 Function:
require_once
could anybody tell me how to load the model, when I work as modules?
I believe the problem is that the library is not finding the model. Check inside ion auth library construct. Look for the line where it says
$this->load->model('ion_auth_model').
It should be line 122 since that's where the error is ocurring. In here you need to prefix the module name - where you have the ion_auth_model - to the model path so the loader class knows where to find it.
In your case if the module's name is directory, then 'directory/ion_auth_model'.
Check this solution https://stackoverflow.com/a/7003180/5785088, point 10, last item. Hope it helps.

custom library and helper not being called in database.php

I am using Codeigniter 3.1.2. I have a custom library and helper which i have auto loaded in autoload.php.
But all of these functions from helper and library not being called when I use these in database.php or in hooks (pre_controller) BUT SYSTEM'S LIBRARIES WORKS FINE THERE LIKE session, router etc etc
database.php
$CI = & get_instance();
echo $CI->nuts_lib->enc($_REQUEST['clid']);
return;
It shows following error
A PHP Error was encountered
Severity: Notice
Message: Undefined property: My_controller::$nuts_lib
Filename: config/database.php
Line Number: 76
Backtrace:
File: C:\xampp\htdocs\my_project\application\config\database.php Line:
76 Function: _error_handler
File: C:\xampp\htdocs\my_project\application\controllers\My_controller.php
Line: 18 Function: __construct
File: C:\xampp\htdocs\my_project\index.php Line: 280 Function:
require_once
I have tried through hooks still not worked. Help Please.
Found a solution. I can use native/system libraries direct in database.php and I have placed my encryption related code there. Now its working
See the flow of CI, Libraries are loaded before Database/Models
https://www.codeigniter.com/user_guide/overview/appflow.html

Unable to locate an appunto-auth model in CI 3

I'm trying to integrate appunto system to my application so I followed the full installation structure from the documentation but all time I got the next message :
An uncaught Exception was encountered
Type: RuntimeException
Message: Unable to locate the model you have specified: Pathmodel
Filename: /var/zpanel/hostdata/zadmin/public_html/git-backup_releasecandidate_net/system/core/Loader.php
Line Number: 344
Backtrace:
File: /var/zpanel/hostdata/zadmin/public_html/git-backup_releasecandidate_net/application/libraries/appunto-auth/Appunto_auth.php
Line: 24
Function: model
File: /var/zpanel/hostdata/zadmin/public_html/git-backup_releasecandidate_net/index.php
Line: 315
Function: require_once
If you are following this guide. You may need to change these lines in Appunto_auth library class.
$this->CI->load->model('appunto-auth/pathmodel');
$this->CI->load->model('appunto-auth/usermodel');
You may remove the appunto-auth folder from the path to the models since they will no longer be in that directory as we have moved it according to the guide.
$this->CI->load->model('pathmodel');
$this->CI->load->model('usermodel');
You may do the same if your app screams about the helper and config files on lines 22 and 15.

CodeIgniter Database Session Error

When I try to execute any controller of my CodeIgniter project i receive this error:
Fatal error: Class CI_Session_files_driver contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (SessionHandlerInterface::read) in D:\Git\crud-farm\system\libraries\Session\drivers\Session_files_driver.php on line 49
A PHP Error was encountered
Severity: Error
Message: Class CI_Session_files_driver contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (SessionHandlerInterface::read)
Filename: drivers/Session_files_driver.php
Line Number: 49
Backtrace:
I tried to replace CodeIgniter system files but it didn't work. The problem appears in all projects
Problem solved by restarting Apache.
I attach the url which saved me: http://forum.codeigniter.com/thread-64763.html
In my case i did the following
Restart apache
That's it!
The files in system should not be modified. My files were modified somehow and were throwing error. I resolved my problem as below.
Download fresh codeigniter and extract files
copy system files from fresh codeigniter into your project and overwrite the whole system folder.
This should fix your problem.

Categories