views:

338

answers:

1

Hello all,

Just started using CodeIgniter, loving it.

Having enabled the database to be one of the libraries to be loaded. I noticed that on pages that I don't even use the database (static pages). CI complains:

A Database Error Occurred Unable to connect to your database server using the provided settings.

The error is not a problem as I haven't supplied the correct username/password. The problem is, would CI try to connect to the database on every page load even though my application doesn't require it on that page or am I missing something?

Or am I missing the point of AutoLoad?

Thanks all

+4  A: 

Autoload in Code Igniter tells the system to load a particular library at each page load. If you have static pages that don't require the database (and you don't want a connection to be made when they are loaded), then you need to stop the database from being autoloaded. You'll also need to manually load the database library on non-static pages where a db connection is necessary.

Marc W
I see. I am guessing applications that need the database on every page exist since they are the only ones able to make good use of AutoLoad? Or are there other scenarios?
Abs
Most applications out there will require the database on each and every page for some reason or another. A lot of applications store the navigation in the database, which is generally on every page. Even static-like pages can be stored as text entries in a table for easy alteration via a CMS or some such management system.
Samir Talwar
Ah, I see. Thank you for the explanation. A simple question I know, but I am complete noob. :)
Abs