11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

www.it-ebooks.infoCHAPTER 31 • INTRODUCING PDOThe column parameter specifies the column offset in the row, whereas the &param parameter definesthe name of the corresponding variable. You can set constraints on the variable value by defining its typeusing the type parameter, and limiting its length using the maxlen parameter. Seven type parametervalues are supported. See the earlier introduction to bindParam() for a complete listing.The following example selects the sku and title columns from the products table where id equals 1,and binds the results according to a numerical offset and associative mapping, respectively:// Output the dataprintf("Product: %s (%s)", $title, $sku);It returns the following:Painless Aftershave (ZP457321)Working with TransactionsPDO offers transaction support for those databases capable of executing transactions. Three PDOmethods facilitate transactional tasks: beginTransaction(), commit(), and rollback(). Because Chapter37 is devoted to transactions, no examples are offered here; instead, brief introductions to these threemethods are offered.Beginning a TransactionThe beginTransaction() method disables autocommit mode, meaning that any database changes willnot take effect until the commit() method is executed. Its prototype follows:boolean PDO::beginTransaction()625

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

Saved successfully!

Ooh no, something went wrong!