CodeIgniter Forums
Trouble with the db connection - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Trouble with the db connection (/showthread.php?tid=73279)



Trouble with the db connection - primadonna - 04-06-2019

I'm trying to retrieve stuff from db, but I'm getting this error:


Code:
Call to undefined function CodeIgniter\Database\MySQLi\mysqli_init()



Code:
SYSTEMPATH/Database\MySQLi\Connection.php at line 107

Code:
107         $this->mysqli = mysqli_init();

My db config:

PHP Code:
public $default = [
        
'DSN'      => '',
        
'hostname' => '0.0.0.0',
        
'username' => 'username',
        
'password' => 'p4ssw0rd',
        
'database' => 'db_name',
        
'DBDriver' => 'MySQLi',
        
'DBPrefix' => '',
        
'pConnect' => false,
        
'DBDebug'  => (ENVIRONMENT !== 'production'),
        
'cacheOn'  => false,
        
'cacheDir' => '',
 
               'charset'  => 'utf8mb4',
        
'DBCollat' => 'utf8_general_ci',
        
'swapPre'  => '',
        
'encrypt'  => false,
        
'compress' => false,
        
'strictOn' => false,
        
'failover' => [],
        
'port'     => 3306,
    ]; 

The query I'm running:
PHP Code:
$query $db->query('SELECT * FROM table_name'); 



I have PHP 7.2.4, MySQL 8 in 5 compatibility mode, Windows 10, CI4 beta 1


RE: Trouble with the db connection - MGatner - 04-07-2019

I’m mobile right now so can’t really look right now but you should definitely start by upgrading to beta 2


RE: Trouble with the db connection - primadonna - 04-07-2019

It's the same thing with beta 2.


RE: Trouble with the db connection - InsiteFX - 04-07-2019

To connect to the database:

PHP Code:
$db = \Config\Database::connect();

// or

$db db_connect(); 



RE: Trouble with the db connection - primadonna - 04-08-2019

I already have
PHP Code:
$db db_connect(); 



RE: Trouble with the db connection - InsiteFX - 04-08-2019

If you change the database charset to utf8mb4 then the database collation should also be changed to utf8mb4_general_ci

Your program charset and collation needs to match what the database table is set to.


RE: Trouble with the db connection - primadonna - 04-08-2019

(04-08-2019, 03:12 AM)InsiteFX Wrote: If you change the database charset to utf8mb4 then the database collation should also be changed to utf8mb4_general_ci

Your program charset and collation needs to match what the database table is set to.

Already tried that, it doesn't help


RE: Trouble with the db connection - titounnes - 04-09-2019

(04-08-2019, 08:10 AM)primadonna Wrote:
(04-08-2019, 03:12 AM)InsiteFX Wrote: If you change the database charset to utf8mb4 then the database collation should also be changed to utf8mb4_general_ci

Your program charset and collation needs to match what the database table is set to.

Already tried that, it doesn't help

Is php-mysqli extension installed?


RE: Trouble with the db connection - primadonna - 04-11-2019

(04-09-2019, 01:22 AM)titounnes Wrote:
(04-08-2019, 08:10 AM)primadonna Wrote:
(04-08-2019, 03:12 AM)InsiteFX Wrote: If you change the database charset to utf8mb4 then the database collation should also be changed to utf8mb4_general_ci

Your program charset and collation needs to match what the database table is set to.

Already tried that, it doesn't help

Is php-mysqli extension installed?

It wasn't /enabled/.

Everything is working now, thanks.