Home arrow PHP arrow Page 3 - Database Details and PHP

Metadata - PHP

Picking up from where we left off last week, we'll be discussing shortcuts, query responses, metadata, and more. This article is excerpted from chapter eight of the book Programming PHP, Second Edition, written by Kevin Tatroe, Rasmus Lerdorf, and Peter MacIntyre (O'Reilly, 2006; ISBN: 0596006810). Copyright © 2006 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

TABLE OF CONTENTS:
  1. Database Details and PHP
  2. Details About a Query Response
  3. Metadata
  4. Sample Application
By: O'Reilly Media
Rating: starstarstarstarstar / 6
June 28, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
 

The getListOf() method lets you query the database for information on available databases, users, views, and functions:

  $data = $db->getListOf(what);

Thewhat  parameter is a string identifying the database feature to list. Most databases support"databases;"some support"users," "views,"and"functions."

For example, this stores a list of available databases in$dbs:

  $dbs = $db->getListOf("databases");

Transactions

Some RDBMSs support transactions, in which a series of database changes can be committed (all applied at once) or rolled back (discarded, with the changes not applied to the database). For example, when a bank handles a money transfer, the withdrawal from one account and deposit into another must happen together—neither should happen without the other, and there should be no time between the two actions. PEAR DB offers the commit () and rollback() methods to help with transactions:

  $res = $db->commit();
 
$res = $db->rollback();

If you callcommit()orrollback()on a database that doesn’t support transactions, the methods returnDB_ERROR.

Be sure to check your underlying database product to ensure that it supports transactions.



 
 
>>> More PHP Articles          >>> More By O'Reilly Media
 

blog comments powered by Disqus
   

PHP ARTICLES

- 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...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 4 - Follow our Sitemap

Dev Shed Tutorial Topics: