CodeIgniter database connections not being closed

前端 未结 6 1411
灰色年华
灰色年华 2021-02-05 04:48

I have built a social community website in CodeIgniter which is now getting a fair bit of traffic, the hosting company have started complaining and saying that the database is r

6条回答
  •  日久生厌
    2021-02-05 05:37

    I think that you're gettting problemns with the initial configurations from Codeigniter connection database.

    At this page, you can see each value from config array:
    https://www.codeigniter.com/user_guide/database/configuration.html

    $db['default']['hostname'] = "localhost";
    $db['default']['username'] = "root";
    $db['default']['password'] = "";
    $db['default']['database'] = "database_name";
    $db['default']['dbdriver'] = "mysql";
    $db['default']['dbprefix'] = "";
    $db['default']['pconnect'] = TRUE;
    $db['default']['db_debug'] = FALSE;
    $db['default']['cache_on'] = FALSE;
    $db['default']['cachedir'] = "";
    $db['default']['char_set'] = "utf8";
    $db['default']['dbcollat'] = "utf8_general_ci";
    $db['default']['swap_pre'] = "";
    $db['default']['autoinit'] = TRUE;
    $db['default']['stricton'] = FALSE;
    

    This it's an basic array config database, try to set the variable of pconnect to FALSE, when it is turned on, the system doesn't close any connection and it stay opened to news queries at any time.

    If you set it to false like i said, your system will continue working perfectly, but the codeigniter will close and open the connection when he need's to use the database.

    Here, you can find and post inside codeigniter forum with a guy that's have a problem with pconnect variables, may help you! http://codeigniter.com/forums/viewthread/177573/#842016

提交回复
热议问题