Your SlideShare is downloading. ×
Database connectivity in ci
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide
  • 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
  • Transcript

    • 1. 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
    • 2. Week Target Achieved 1 --- 20 2 25 22 3 25 Typing Speed
    • 3. Jobs Applied # Company Designation Applied Date Current Status 1 2 3
    • 4. Database Connectivity using codeIgniter SWALIH T www.facebook/ swalih321 9539353663
    • 5. 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
    • 6. 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
    • 7. 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);
    • 8. 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.
    • 9. 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();
    • 10. Manually closing the Connection • While CodeIgniter intelligently takes care of closing your database connections, you can explicitly close the connection. • $this->db->close();
    • 11. If this presentation helped you, please visit our page and like it. | |
    • 12. 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: