Check if database connection can be etablished on CodeIgniter 3
<p>My application can be used with or without a database so I need to know if a database is correctly configured to show or hide functionalities which require a database.</p>

<p>How can I access to database config vars to check if they are filled?</p>

<p>Everything I found on the web requires to do a <code>$this-&gt;load-&gt;database();</code> so I can access to database vars from the <code>$this-&gt;db</code> object.</p>

<p>The problem is that if we do not have a database or if the database config file is not properly set, <code>$this-&gt;load-&gt;database();</code> will results in a PHP error:</p>

<blockquote>
  <p>Unable to connect to your database server using the provided settings.</p>
</blockquote>