I am sure people know how to do this with CI 3, but if you run into issues like I did using the adapter this works really well.
I just put this code in my base controller class. Now I can easily just use the existing CI 3 db connection info and get a DT object. Maybe useful as an example?
public function getDBConfig() {
$config = [
'host' => $this->db->hostname,
'port' => '3306',
'username' => $this->db->username,
'password' => $this->db->password,
'database' => $this->db->database
];
return $config;
}
public function getDatatables() {
return (new Datatables( new MySQL($this->getDBConfig())));
}
I am sure people know how to do this with CI 3, but if you run into issues like I did using the adapter this works really well.
I just put this code in my base controller class. Now I can easily just use the existing CI 3 db connection info and get a DT object. Maybe useful as an example?