11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

www.it-ebooks.infoCHAPTER 31 • INTRODUCING PDO<strong>MySQL</strong>, just load the PDO_MYSQL driver (more about how to do this later in thechapter).• Object-oriented features: PDO takes advantage of <strong>PHP</strong> 5’s object-orientedfeatures, resulting in a more refined approach to database interaction thanmany preceding solutions.• Performance: PDO is written in C and compiled into <strong>PHP</strong>, which, all otherthings being equal, provides a considerable performance increase oversolutions written in <strong>PHP</strong>.Given such advantages, what’s not to like? This chapter serves to fully acquaint you with PDO andthe myriad features it has to offer.Using PDOPDO bears a striking resemblance to all of the database extensions long supported by <strong>PHP</strong>. Therefore,for those of you who have used <strong>PHP</strong> in conjunction with a database, the material presented in thissection should be quite familiar. As mentioned, PDO was built with the best features of the precedingdatabase extensions in mind, so it makes sense that you’ll see a marked similarity in its methods.This section commences with a quick overview of the PDO installation process, and follows with asummary of its presently supported database servers. For the purposes of the examples foundthroughout the remainder of this chapter, the following <strong>MySQL</strong> table is used:CREATE TABLE products (id INT NOT NULL AUTO_INCREMENT,sku CHAR(8) NOT NULL,title VARCHAR(100) NOT NULL,PRIMARY KEY(id));The table has been populated with the products listed in Table 31-1.Table 31-1. Sample Product DataId sku title1 ZP457321 Painless Aftershave2 TY232278 AquaSmooth Toothpaste3 PO988932 HeadsFree Shampoo4 KL334899 WhiskerWrecker Razors609

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!