Welcome Guest, Not a member yet? Register   Sign In
HELP!! Database needs to be reconnected
#4

[eluser]Namulator[/eluser]
Well, after reading the source code for the various DB libs, I found out how to accomplish my goal, but I do believe there is one draw back. There is one extra connection attempt to the DB which occurs, then is dropped immediately. This occurs once during the initial process start, which is a waste of a connection, but perhaps I or someone here will find a way around that...

Here's what I have done...

------------------Stripped down code------------------
Code:
class DaemonLib{
  function Start() {
    $CI =& get_instance();
    $CI->load->database();
    $CI->db->close();
    $pid = pcntl_fork();
    if ($pid == -1) {
      if ($this->Debug==TRUE) echo "Failed to fork";
    } else {
      $CI->db->initialize();
      /* Do code calls within new process here */
    }
  }
}
------------------Stripped down code------------------

Because the first "$CI->load->database();" connection is not required for this library, I have to scrap the connection by calling the close call. Then, once the new thread has been forked, I can then re-initialize the connection, which is then working within that thread.


Does anyone know of a way to load the library, without having it connect upon loading the library?... I tried doing "$CI->load->library('database');" but that did not work.


Messages In This Thread
HELP!! Database needs to be reconnected - by El Forum - 11-19-2007, 07:18 PM
HELP!! Database needs to be reconnected - by El Forum - 11-19-2007, 10:58 PM
HELP!! Database needs to be reconnected - by El Forum - 11-20-2007, 01:08 AM
HELP!! Database needs to be reconnected - by El Forum - 11-20-2007, 07:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB