[Cs-content-commits] SF.net SVN: cs-content:[408] trunk/1.0
PHP Templating & Includes System
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-07-20 18:58:32
|
Revision: 408 http://cs-content.svn.sourceforge.net/cs-content/?rev=408&view=rev Author: crazedsanity Date: 2009-07-20 18:58:30 +0000 (Mon, 20 Jul 2009) Log Message: ----------- Add information for debugging, MySQL transactions shouldn't autocommit. /cs_phpDB.class.php: * run_update(): -- add the SQL string to the error so it can be debugged. /db_types/cs_phpDB__mysql.class.php: * beginTrans(): -- turn off autocommit so changes aren't committed unless the transaction actually succeeded. Modified Paths: -------------- trunk/1.0/cs_phpDB.class.php trunk/1.0/db_types/cs_phpDB__mysql.class.php Modified: trunk/1.0/cs_phpDB.class.php =================================================================== --- trunk/1.0/cs_phpDB.class.php 2009-07-20 05:26:02 UTC (rev 407) +++ trunk/1.0/cs_phpDB.class.php 2009-07-20 18:58:30 UTC (rev 408) @@ -31,6 +31,7 @@ private $dbLayerObj; private $dbType; + public $connectParams = array(); //========================================================================= public function __construct($type='pgsql') { @@ -60,6 +61,10 @@ */ public function __call($methodName, $args) { if(method_exists($this->dbLayerObj, $methodName)) { + if($methodName == 'connect' && is_array($args[0])) { + //capture the connection parameters. + $this->connectParams = $args[0]; + } $retval = call_user_func_array(array($this->dbLayerObj, $methodName), $args); } else { @@ -133,13 +138,13 @@ /** * Handles performing the insert statement & returning the last inserted ID. */ - public function run_insert($sql, $sequence='null') { + public function run_insert($sql) { $this->exec($sql); if($this->numAffected() == 1 && !strlen($this->errorMsg())) { //retrieve the ID just created. - $retval = $this->lastID($sequence); + $retval = $this->lastID(); } else { //something broke... @@ -163,13 +168,26 @@ $numAffected = $this->numAffected(); if($numAffected==0 && $zeroIsOk == false) { - throw new exception(__METHOD__ .": no rows updated (". $numAffected .")"); + throw new exception(__METHOD__ .": no rows updated (". $numAffected ."), SQL::: ". $sql); } return($numAffected); }//end run_update() //========================================================================= + + + //========================================================================= + public function reconnect() { + if(is_array($this->connectParams) && count($this->connectParams)) { + $this->dbLayerObj->connect($this->connectParams, true); + } + else { + throw new exception(__METHOD__ .": no connection parameters stored"); + } + }//end reconnect() + //========================================================================= + } // end class phpDB ?> Modified: trunk/1.0/db_types/cs_phpDB__mysql.class.php =================================================================== --- trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-07-20 05:26:02 UTC (rev 407) +++ trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-07-20 18:58:30 UTC (rev 408) @@ -793,7 +793,7 @@ //========================================================================= public function beginTrans() { - $this->exec('BEGIN'); + $this->exec('BEGIN;SET autocommit=0;'); return(true); }//end beginTrans() //========================================================================= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |