Database connectivity in ci
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share
  • 540 views

 

Statistics

Views

Total Views
540
Views on SlideShare
540
Embed Views
0

Actions

Likes
0
Downloads
4
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • 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

Database connectivity in ci Presentation 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 swalihk321@gmail.com www.facebook/ swalih321 twitter.com/swalih321 in.linkedin.com/in/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 facebook.com/baabtra and like it. www.baabtra.com | www.massbaab.com |www.baabte.com
  • 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