On October 23rd, 2014, we updated our
By continuing to use LinkedIn’s SlideShare service, you agree to the revised terms, so please take a few minutes to review them.
Database connectivity in ciPresentation Transcript
Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .
# Company Designation Applied Date Current Status
Database Connectivity using
• Models are PHP classes that are designed to
work with information in your database.
• The "auto connect" feature will load and
instantiate the database class with every page
load. To enable "auto connecting", add the
word database to the library array, as
indicated in the following file:
These are the things you can load automatically:
• 1. Packages
• 2. Libraries
• 3. Helper files
• 4. Custom config files
• 5. Language files
• 6. Models
• If only some of your pages require database
connectivity you can manually connect to your
database by adding this line of code in any
function where it is needed, or in your class
constructor to make the database available
globally in that class.
• When a model is loaded it does not connect
automatically to your database.
• $this->load->model('Model_name', ' ', TRUE);
• CodeIgniter has a config file that lets you store
your database connection values (username,
password, database name, etc.).
• The config file is located
at application/config/database.php. You can
also set database connection values for
specific environments by
placing database.php it the respective
environment config folder.
Reconnecting / Keeping the
• If the database server's idle timeout is
exceeded while you're doing some heavy PHP
lifting (processing an image, for instance), you
should consider pinging the server by using
the reconnect() method before sending
further queries, which can gracefully keep the
connection alive or re-establish it.
Manually closing the Connection
• While CodeIgniter intelligently takes care of
closing your database connections, you can
explicitly close the connection.
If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
www.baabtra.com | www.massbaab.com |www.baabte.com
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Ph: + 91 – 495 40 25 550
Start up Village