[eluser]veledrom[/eluser]
Hi,
I'm not autoloading db because most of my application don't need db processing otherwise whole thing will slow down. What I want to do is not to establish a new connection to db when there is one already alive and use it instead not to bother server-db. So how do I implement
$this->db->reconnect(); to my example below?
Note : If I need to use
$this->db->close(); and
$this->db->initialize(); then please help me implement them as well because I heard that calling
reconnect() with auto-reconnect disabled in MySQL will throw an error.
I'm using CI 2.1
Thanks
Code:
class Test_model extends CI_Model
{
public function __construct()
{
parent::__construct();
$this->load->database();
}
public function call_me_first($id)
{
$this->db->protect_identifiers('year');
$sql = "SELECT * FROM year WHERE id = ?";
$data['dbquery'] = $this->db->query($sql, array($id));
return $data['dbquery'];
}
public function call_me_after($id)
{
$this->db->protect_identifiers('month');
$sql = "SELECT * FROM month WHERE id = ?";
$data['dbquery'] = $this->db->query($sql, array($id));
return $data['dbquery'];
}
public function call_me_last($id)
{
$this->db->protect_identifiers('day');
$sql = "SELECT * FROM day WHERE id = ?";
$data['dbquery'] = $this->db->query($sql, array($id));
return $data['dbquery'];
}
}