Home arrow PHP arrow Working with Prepared Queries with PDO Objects in PHP 5

Working with Prepared Queries with PDO Objects in PHP 5

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).

TABLE OF CONTENTS:
  1. Working with Prepared Queries with PDO Objects in PHP 5
  2. Working with prepared queries
  3. Using an alternate approach with prepared queries
  4. Working with transactions
By: Alejandro Gervasio
Rating: starstarstarstarstar / 8
June 11, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: