Home arrow PHP arrow Page 2 - Code 10x More Efficiently Using Data Access Objects: Part 1
PHP

Code 10x More Efficiently Using Data Access Objects: Part 1


Learn how to efficiently access database information using Data Access Objects (DAO) with PHP. Oto shows us how easy database manipulation can be, as well as how much time can be saved.

Author Info:
By: Oto Hlincik
Rating: 4 stars4 stars4 stars4 stars4 stars / 51
October 11, 2003
TABLE OF CONTENTS:
  1. · Code 10x More Efficiently Using Data Access Objects: Part 1
  2. · The Old Way
  3. · Code Samples, The Old Way
  4. · Database DAO to the Rescue
  5. · Convenience and Performance
  6. · Conclusion

print this article
SEARCH DEVARTICLES

Code 10x More Efficiently Using Data Access Objects: Part 1 - The Old Way
(Page 2 of 6 )

As mentioned earlier, PHP provides great built-in functions that allow the developer to connect to a database and retrieve some data. (If you are an experienced PHP programmer and do not feel like getting bored with the "same old", skip ahead to the section titled "Database DAO to the Rescue"). 

In what ways do we usually need the data returned from a database, and in what format do we like to have the data returned? In my years of development I have realized that in overwhelming majority of cases I need to have my data returned in three ways: as a single value, as one record, and as many records.

Let's see how we would go about getting a value, a record, and a recordset returned from the database the "old way." PHP is most frequently coupled with the MySQL database software, so let's use it for our example. I have a contact database with a "Contacts" table full of, you guessed it, contacts. The database is accessible on the "localhost", the user is "user", the password is "password", and the table structure looks something like this:

Table Contacts

FieldType Key Null? 
id int(11) PRI  
first_namevarchar(64)  
last_namevarchar(64)  
phonevarchar(20) YES 
emailvarchar(64) YES


blog comments powered by Disqus
PHP ARTICLES

- Removing Singletons in PHP
- Singletons in PHP
- Implement Facebook Javascript SDK with PHP
- Making Usage Statistics in PHP
- Installing PHP under Windows: Further Config...
- File Version Management in PHP
- Statistical View of Data in a Clustered Bar ...
- Creating a Multi-File Upload Script in PHP
- Executing Microsoft SQL Server Stored Proced...
- Code 10x More Efficiently Using Data Access ...
- A Few Tips for Speeding Up PHP Code
- The Modular Web Page
- Quick E-Commerce with PHP and PayPal
- Regression Testing With JMeter
- Building an Iterator with PHP

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials