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