I'm trying to check id database connection exist or not then redirect to a page where a user can be able to create a database through form inputs.
Here's what I tried to do but not succeed.
public function index()
{
// $database = \Config\Database::connect();
$database = \CodeIgniter\Database\Config::getConnections();
if ($database)
{
//db connection initialized
return view('dashboard');
}
else
{
//db connection not initialized
return redirect('db_setup');
}
}