Index: trunk/psLib/src/db/psDB.c
===================================================================
--- trunk/psLib/src/db/psDB.c	(revision 7050)
+++ trunk/psLib/src/db/psDB.c	(revision 7070)
@@ -12,6 +12,6 @@
  *  @author Joshua Hoblitt
  *
- *  @version $Revision: 1.49 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-05-03 02:35:37 $
+ *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-05-05 02:42:01 $
  *
  *  Copyright 2005 Joshua Hoblitt, University of Hawaii
@@ -123,4 +123,15 @@
     dbh->mysql = mysql;
 
+    // explicit transactions default to false
+    if (!psDBExplicitTrans(dbh, false)) {
+        psError(PS_ERR_UNKNOWN, true,
+                "failed to set transaction type", mysql_error(mysql));
+
+        mysql_close(mysql);
+        psFree(dbh);
+
+        return NULL;
+    }
+
     return dbh;
 }
@@ -688,7 +699,4 @@
     } // end loop over rows
 
-    // point of no return
-    mysql_commit(dbh->mysql);
-
     psFree(bind);
     mysql_stmt_close(stmt);
@@ -838,7 +846,4 @@
     rowsAffected = mysql_stmt_affected_rows(stmt);
 
-    // point of no return
-    mysql_commit(dbh->mysql);
-
     mysql_stmt_close(stmt);
 
@@ -879,7 +884,4 @@
     rows = (psS64)mysql_affected_rows(dbh->mysql);
 
-    // point of no return
-    mysql_commit(dbh->mysql);
-
     return rows;
 }
@@ -890,4 +892,60 @@
     return (long)mysql_insert_id(dbh->mysql);
 }
+
+bool psDBExplicitTrans(psDB *dbh, bool mode)
+{
+    // Verify database is not NULL
+    if(dbh == NULL) {
+        psError(PS_ERR_UNEXPECTED_NULL, true, PS_ERRORTEXT_psDB_INVALID_PSDB);
+        return false;
+    }
+
+    // mode needs to be inverted as autocommits are the opposide of explicit
+    // transactions.
+    // the return value also needs to be inverted for the same reason.
+    // is it safe to assume my_bool always safely casts to bool?
+    return !(bool)mysql_autocommit(dbh->mysql, !mode);
+}
+
+bool psDBTransaction(psDB *dbh)
+{
+    // Verify database is not NULL
+    if(dbh == NULL) {
+        psError(PS_ERR_UNEXPECTED_NULL, true, PS_ERRORTEXT_psDB_INVALID_PSDB);
+        return false;
+    }
+
+    bool status = p_psDBRunQuery(dbh, "START TRANSACTION");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "Failed to create new database.");
+    }
+
+    return status;
+}
+
+bool psDBCommit(psDB *dbh)
+{
+    // Verify database is not NULL
+    if(dbh == NULL) {
+        psError(PS_ERR_UNEXPECTED_NULL, true, PS_ERRORTEXT_psDB_INVALID_PSDB);
+        return false;
+    }
+
+    // is it safe to assume my_bool always safely casts to bool?
+    return (bool)mysql_commit(dbh->mysql);
+}
+
+bool psDBRollback(psDB *dbh)
+{
+    // Verify database is not NULL
+    if(dbh == NULL) {
+        psError(PS_ERR_UNEXPECTED_NULL, true, PS_ERRORTEXT_psDB_INVALID_PSDB);
+        return false;
+    }
+
+    // is it safe to assume my_bool always safely casts to bool?
+    return (bool)mysql_rollback(dbh->mysql);
+}
+
 
 // database utility functions
Index: trunk/psLib/src/db/psDB.h
===================================================================
--- trunk/psLib/src/db/psDB.h	(revision 7050)
+++ trunk/psLib/src/db/psDB.h	(revision 7070)
@@ -10,6 +10,6 @@
  *  @author Joshua Hoblitt
  *
- *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-05-03 02:35:37 $
+ *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-05-05 02:42:01 $
  *
  *  Copyright 2005 Joshua Hoblitt, University of Hawaii
@@ -285,4 +285,48 @@
 );
 
+/** Enable/Disable explicit database transactions
+ *
+ * This function is used to enable explicit transaction support.  It is off by
+ * default.
+ *
+ * @return bool:    true if transactions are enabled
+ */
+bool psDBExplicitTrans(
+    psDB *dbh,                          ///< Database handle
+    bool mode                           ///< transactions enable/disable
+);
+
+/** Start a new transaction set.
+ *
+ * This is only a meaningful action if explict transactions are disabled.
+ *
+ * @return bool:    true on success
+ */
+bool psDBTransaction(
+    psDB *dbh                           ///< Database handle
+);
+
+/** Commits the current transaction
+ *
+ * This function will commit the current transaction set (a rollback is not
+ * possible after this function is successfully executed).  A commit also
+ * effectively starts a new transaction if explict transactions are enabled.
+ *
+ * @return bool:    true on success
+ */
+bool psDBCommit(
+    psDB *dbh                           ///< Database handle
+);
+
+/** Rollback the current transaction
+ *
+ * This function will rollback the current transaction set.
+ *
+ * @return bool:    true on success
+ */
+bool psDBRollback(
+    psDB *dbh                           ///< Database handle
+);
+
 /// @}
 
