File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / pdo / README
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:47:58 2012 UTC (12 years, 5 months ago) by misho
Branches: php, MAIN
CVS tags: v5_3_10, HEAD
php

    1: $Id: README,v 1.1.1.1 2012/02/21 23:47:58 misho Exp $
    2: 
    3: PHP Data Objects
    4: ================
    5: 
    6: Concept: Data Access Abstraction
    7: 
    8: Goals:
    9: 
   10: 1/  Be light-weight
   11: 2/  Provide common API for common database operations
   12: 3/  Be performant
   13: 4/  Keep majority of PHP specific stuff in the PDO core (such as persistent
   14:     resource management); drivers should only have to worry about getting the
   15:     data and not about PHP internals.
   16: 
   17: 
   18: Transactions and autocommit
   19: ===========================
   20: 
   21: When you create a database handle, you *should* specify the autocommit
   22: behaviour that you require.  PDO will default to autocommit on.
   23: 
   24: $dbh = new PDO("...", $user, $pass, array(PDO_ATTR_AUTOCOMMIT => true));
   25: 
   26: When auto-commit is on, the driver will implicitly commit each query as it is
   27: executed.  This works fine for most simple tasks but can be significantly
   28: slower when you are making a large number of udpates.
   29: 
   30: $dbh = new PDO("...", $user, $pass, array(PDO_ATTR_AUTOCOMMIT => false));
   31: 
   32: When auto-commit is off, you must then use $dbh->beginTransaction() to
   33: initiate a transaction.  When your work is done, you then call $dbh->commit()
   34: or $dbh->rollBack() to persist or abort your changes respectively.  Not all
   35: databases support transactions.
   36: 
   37: You can change the auto-commit mode at run-time:
   38: 
   39: $dbh->setAttribute(PDO_ATTR_AUTOCOMMIT, false);
   40: 
   41: Regardless of the error handling mode set on the database handle, if the
   42: autocommit mode cannot be changed, an exception will be thrown.
   43: 
   44: Some drivers will allow you to temporarily disable autocommit if you call
   45: $dbh->beginTransaction().  When you commit() or rollBack() such a transaction,
   46: the handle will switch back to autocommit mode again.  If the mode could not
   47: be changed, an exception will be raised, as noted above.
   48: 
   49: When the database handle is closed or destroyed (or at request end for
   50: persistent handles), the driver will implicitly rollBack().  It is your
   51: responsibility to call commit() when you are done making changes and
   52: autocommit is turned off.
   53: 
   54: vim:tw=78:et
   55: 
   56: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>