PHP
  Home arrow PHP arrow Working with Prepared Queries with PDO...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Working with Prepared Queries with PDO Objects in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    2007-06-11

    Table of Contents:
  • Working with Prepared Queries with PDO Objects in PHP 5
  • Working with prepared queries
  • Using an alternate approach with prepared queries
  • Working with transactions

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Working with Prepared Queries with PDO Objects in PHP 5


    (Page 1 of 4 )

    If you're a PHP developer who builds web applications that interact with different database systems, such as MySQL, Oracle, MS SQL, and so forth, then this group of articles might be what you're looking for. Welcome to the final part of the series that began with "Using PDO objects in PHP 5." This series shows you how to implement the most important methods that come packaged with the PDO database abstraction layer (short for PHP Data Objects).

    Introduction

    In the preceding article of the series, I proceeded to cover in detail a few simple methods bundled with the PDO library for performing some common tasks associated with diverse database systems. These tasks included fetching and counting the number rows present in a given result set, retrieving specific columns, and finally determining how many records were affected after executing an INSERT, UPDATE and DELETE command.

    Of course, it's important to stress here that the aforementioned operations, and the ones discussed in the first article of the series, can be easily performed using a great variety of database servers, including the most popular ones, such as MySQL, MS SQL, Oracle. This clearly reveals the real power that stands behind this robust PHP-based database abstraction layer.

    Okay, at this point you may be thinking that the functionality brought by PDO objects is limited to connecting to multiple database systems, performing a few basic database-related tasks, and that's it. Actually, the extension has been provided with many more useful features, including its capability for working with prepared queries.

    As you'll probably recall, I already introduced the concept of prepared queries through the implementation of the "prepare()" and "execute()" methods of the PDO extension, right at the beginning of this series. As I said then, however, it was only an introduction to the topic.

    Indeed, this subject is far much complex, and deserves a more detailed analysis. Therefore, in this last tutorial in the series I'm going to show you how to run prepared queries, but in this case we're going to include named parameters into them. Additionally, I'm going to take a quick look at some additional methods bundled with this extension. These new methods can be really useful for working with transactions, in case you want to use this feature with the database system of your choice.

    Hopefully, by the end of this article, you should have a more solid background in how to include these neat characteristics in your own PHP applications with the assistance of the PDO extension.

    With the preliminaries out of our way, let's explore the real power of using prepared queries and transactions with PDO objects. It's going to be an instructive experience!

    More PHP Articles
    More By Alejandro Gervasio


       · Over the course of this second tutorial of the series, you'll learn how to work with...
       · $dbh->prepare('SELECT * FROM users WHERE name=? AND...
       · Thank you for your pointing me out that small bug on my PHP example. The PDO code...
     

       

    PHP ARTICLES

    - Viewing and Editing Tasks for a Project Mana...
    - More on Private Methods with PHP 5 Member Vi...
    - Adding Tasks to a Project Management Applica...
    - Utilizing Private Methods with PHP 5 and Mem...
    - Making Changes in a Project Management Appli...
    - Defining Public and Protected Methods with M...
    - HTML for a Project Management Application
    - Using Subclasses and Accessors with Member V...
    - Implementing Internet Protocols with PHP
    - Project Management: The Application
    - Working with Private Properties to Protect P...
    - Protecting PHP 5 Class Data with Member Visi...
    - Setting Up a Web-based Image Hosting Service
    - Comparing Files and Databases with PHP Bench...
    - Setting Up a Web-Based Image Gallery





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway