Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Database connectivity in ci

599 views

Published on

Published in: Education, Technology
  • Be the first to comment

  • Be the first to like this

Database connectivity in ci

  1. 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. 2. Week Target Achieved 1 --- 20 2 25 22 3 25 Typing Speed
  3. 3. Jobs Applied # Company Designation Applied Date Current Status 1 2 3
  4. 4. Database Connectivity using codeIgniter SWALIH T swalihk321@gmail.com www.facebook/ swalih321 twitter.com/swalih321 in.linkedin.com/in/swalih321 9539353663
  5. 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. 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. 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. 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. 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. 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. 11. If this presentation helped you, please visit our page facebook.com/baabtra and like it. www.baabtra.com | www.massbaab.com |www.baabte.com
  12. 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: info@baabtra.com

×