n1crack / datatables

Simplify your Datatables server-side processing effortlessly using our lightning-fast PHP library, streamlining your workflow seamlessly.
https://datatables.ozdemir.be/
MIT License
266 stars 89 forks source link

another eample #73

Closed Goddard closed 3 years ago

Goddard commented 3 years ago

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())));
    }