SlideShare a Scribd company logo
Database connectivity in ci
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 .
Ltd
Week Target Achieved
1 --- 20
2 25 22
3 25
Typing Speed
Jobs Applied
# Company Designation Applied Date Current Status
1
2
3
Database Connectivity using
codeIgniter
SWALIH T
swalihk321@gmail.com
www.facebook/ swalih321
twitter.com/swalih321
in.linkedin.com/in/swalih321
9539353663
Automatically Connecting
• 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:
• application/config/autoload.php
Continue..
These are the things you can load automatically:
• 1. Packages
• 2. Libraries
• 3. Helper files
• 4. Custom config files
• 5. Language files
• 6. Models
Manually Connecting
• 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.
• $this->load->database();
• When a model is loaded it does not connect
automatically to your database.
• $this->load->model('Model_name', ' ', TRUE);
Database Configuration
• 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.
Database connectivity in ci
Reconnecting / Keeping the
Connection Alive
• 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.
• $this->db->reconnect();
Manually closing the Connection
• While CodeIgniter intelligently takes care of
closing your database connections, you can
explicitly close the connection.
• $this->db->close();
If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
www.baabtra.com | www.massbaab.com |www.baabte.com
Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com

More Related Content

PDF
Different Concepts on Databases
PPTX
Database Component
PPTX
How to use bean as datasource in database connector
PPT
Sql interview-question-part-9
PPT
Ebook9
PPTX
Database component in mule
PDF
phpWebApp presentation
PPT
Mule database connector
Different Concepts on Databases
Database Component
How to use bean as datasource in database connector
Sql interview-question-part-9
Ebook9
Database component in mule
phpWebApp presentation
Mule database connector

What's hot (18)

PDF
IRJET- Review on Java Database Connectivity
PDF
JDBC-Introduction
PDF
Introduction to CakePHP
PDF
Overview Of JDBC
PPT
PPS
Jdbc architecture and driver types ppt
PPTX
Tool review Mongolab
PPT
Struts 2-overview2
PPTX
How to use data mapper transformer
DOC
File uploading through paperclip in rails 3.x
PPT
PPTX
PPT
JDBC Connectivity Model
PPT
Java database connectivity
DOC
jdbc document
PPTX
Java- JDBC- Mazenet Solution
PPT
Ebook7
PPTX
IRJET- Review on Java Database Connectivity
JDBC-Introduction
Introduction to CakePHP
Overview Of JDBC
Jdbc architecture and driver types ppt
Tool review Mongolab
Struts 2-overview2
How to use data mapper transformer
File uploading through paperclip in rails 3.x
JDBC Connectivity Model
Java database connectivity
jdbc document
Java- JDBC- Mazenet Solution
Ebook7
Ad

Similar to Database connectivity in ci (20)

PDF
Data load utility
DOCX
DBM 380 EDU Knowledge is divine-dbm380edu.com
DOCX
DBM 380 HELP Knowledge is divine-dbm380help.com
PDF
Dbm 380 Teaching Effectively--tutorialrank.com
PDF
Enhance Your Flask Web Project With a Database Python Guide.pdf
PPTX
Asp .net folders and web.config
DOC
DBM 380 Invent Yourself/newtonhelp.com
PPT
Uklug 2014 connections dev faq
PDF
DBM 380 EDU Education Planning--dbm380edu.com
DOCX
DBM 380 AID Introduction Education--dbm380aid.com
PDF
PDF
Visual basic databases
PDF
DBM 380 AID Achievement Education--dbm380aid.com
PDF
DBM 380 AID Inspiring Innovation--dbm380aid.com
PDF
Scaling PHP apps
PPTX
Asp .net folders and web.config
DOCX
DBM 380 EDU Wonderful Education--dbm380edu.com
PPTX
Spring data jpa are used to develop spring applications
PDF
DevOps and Decoys How to Build a Successful Microsoft DevOps Including the Data
Data load utility
DBM 380 EDU Knowledge is divine-dbm380edu.com
DBM 380 HELP Knowledge is divine-dbm380help.com
Dbm 380 Teaching Effectively--tutorialrank.com
Enhance Your Flask Web Project With a Database Python Guide.pdf
Asp .net folders and web.config
DBM 380 Invent Yourself/newtonhelp.com
Uklug 2014 connections dev faq
DBM 380 EDU Education Planning--dbm380edu.com
DBM 380 AID Introduction Education--dbm380aid.com
Visual basic databases
DBM 380 AID Achievement Education--dbm380aid.com
DBM 380 AID Inspiring Innovation--dbm380aid.com
Scaling PHP apps
Asp .net folders and web.config
DBM 380 EDU Wonderful Education--dbm380edu.com
Spring data jpa are used to develop spring applications
DevOps and Decoys How to Build a Successful Microsoft DevOps Including the Data
Ad

More from baabtra.com - No. 1 supplier of quality freshers (20)

PPTX
Agile methodology and scrum development
PDF
Acquiring new skills what you should know
PDF
Baabtra.com programming at school
PDF
99LMS for Enterprises - LMS that you will love
PPTX
Chapter 6 database normalisation
PPTX
Chapter 5 transactions and dcl statements
PPTX
Chapter 4 functions, views, indexing
PPTX
PPTX
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
PPTX
Chapter 1 introduction to sql server
PPTX
Chapter 1 introduction to sql server
Agile methodology and scrum development
Acquiring new skills what you should know
Baabtra.com programming at school
99LMS for Enterprises - LMS that you will love
Chapter 6 database normalisation
Chapter 5 transactions and dcl statements
Chapter 4 functions, views, indexing
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 1 introduction to sql server
Chapter 1 introduction to sql server

Recently uploaded (20)

PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
01-Introduction-to-Information-Management.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
GDM (1) (1).pptx small presentation for students
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
master seminar digital applications in india
PPTX
Institutional Correction lecture only . . .
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Computing-Curriculum for Schools in Ghana
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Pharma ospi slides which help in ospi learning
Renaissance Architecture: A Journey from Faith to Humanism
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Module 4: Burden of Disease Tutorial Slides S2 2025
01-Introduction-to-Information-Management.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
2.FourierTransform-ShortQuestionswithAnswers.pdf
O7-L3 Supply Chain Operations - ICLT Program
GDM (1) (1).pptx small presentation for students
VCE English Exam - Section C Student Revision Booklet
human mycosis Human fungal infections are called human mycosis..pptx
O5-L3 Freight Transport Ops (International) V1.pdf
Anesthesia in Laparoscopic Surgery in India
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
master seminar digital applications in india
Institutional Correction lecture only . . .
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
Computing-Curriculum for Schools in Ghana
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Pharma ospi slides which help in ospi learning

Database connectivity in ci

  • 2. 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 . Ltd
  • 3. Week Target Achieved 1 --- 20 2 25 22 3 25 Typing Speed
  • 4. Jobs Applied # Company Designation Applied Date Current Status 1 2 3
  • 5. Database Connectivity using codeIgniter SWALIH T swalihk321@gmail.com www.facebook/ swalih321 twitter.com/swalih321 in.linkedin.com/in/swalih321 9539353663
  • 6. Automatically Connecting • 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: • application/config/autoload.php
  • 7. Continue.. These are the things you can load automatically: • 1. Packages • 2. Libraries • 3. Helper files • 4. Custom config files • 5. Language files • 6. Models
  • 8. Manually Connecting • 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. • $this->load->database(); • When a model is loaded it does not connect automatically to your database. • $this->load->model('Model_name', ' ', TRUE);
  • 9. Database Configuration • 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.
  • 11. Reconnecting / Keeping the Connection Alive • 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. • $this->db->reconnect();
  • 12. Manually closing the Connection • While CodeIgniter intelligently takes care of closing your database connections, you can explicitly close the connection. • $this->db->close();
  • 13. If this presentation helped you, please visit our page facebook.com/baabtra and like it. www.baabtra.com | www.massbaab.com |www.baabte.com
  • 14. Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com

Editor's Notes

  • #9: You can tell the model loading function to auto-connect by passing TRUE (boolean) via the third parameter, and connectivity settings, as defined in your database config file will be used:S