[Cs-content-commits] SF.net SVN: cs-content:[403] trunk/1.0
PHP Templating & Includes System
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-07-06 16:02:29
|
Revision: 403 http://cs-content.svn.sourceforge.net/cs-content/?rev=403&view=rev Author: crazedsanity Date: 2009-07-06 16:02:22 +0000 (Mon, 06 Jul 2009) Log Message: ----------- Minor fixes for update logic. /cs_phpDB.class.php: * run_update() [NEW]: -- simple logic for running updates ("run_query()" fails, since it attempts to call numRows() without checking numAffected()). /db_types/cs_phpDB__mysql.class.php: * numRows(): -- return 0 if the result is null OR if it isn't a valid resource. 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-02 15:40:51 UTC (rev 402) +++ trunk/1.0/cs_phpDB.class.php 2009-07-06 16:02:22 UTC (rev 403) @@ -151,6 +151,25 @@ }//end run_insert() //========================================================================= + + + //========================================================================= + /** + * Performs the update & returns how many rows were affected. + */ + public function run_update($sql, $zeroIsOk=false) { + $this->exec($sql); + + $numAffected = $this->numAffected(); + + if($numAffected==0 && $zeroIsOk == false) { + throw new exception(__METHOD__ .": no rows updated (". $numAffected .")"); + } + + return($numAffected); + }//end run_update() + //========================================================================= + } // 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-02 15:40:51 UTC (rev 402) +++ trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-07-06 16:02:22 UTC (rev 403) @@ -635,11 +635,10 @@ * Returns the number of rows in a result (from a SELECT query). */ function numRows() { - if ($this->result == null) { + if ($this->result == null || !is_resource($this->result)) { $retval = 0; } else { - //TODO: implement MySQL version.. $this->numrows = mysql_num_rows($this->result); $retval = $this->numrows; } @@ -670,7 +669,6 @@ $retval = 0; } else { - //TODO: implement MySQL version.. $retval = mysql_num_fields($this->result); } return($retval); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |