Connecting MySQL Database in CodeIgniter — a practical guide to CodeIgniter MySQL with clear examples you can reuse in real projects.
CodeIgniter Tutorial Series (30/74). Prefer one article? Read the complete CodeIgniter tutorial.
Short description
Once `.env` is set, use the database service or models. Test with a simple query during setup.
Test connection
$db = ConfigDatabase::connect();
$query = $db->query('SELECT 1 AS ok');
print_r($query->getRow());