[Cs-content-commits] SF.net SVN: cs-content:[410] trunk/1.0
PHP Templating & Includes System
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-07-21 03:21:22
|
Revision: 410 http://cs-content.svn.sourceforge.net/cs-content/?rev=410&view=rev Author: crazedsanity Date: 2009-07-21 03:21:21 +0000 (Tue, 21 Jul 2009) Log Message: ----------- Fix sql quoting, insert style to allows non-quoted NULLs, update gives error. /cs_globalFunctions.class.php: * switch_force_sql_quotes(): -- if there's no new setting but an old value exists, use that instead of throwing an exception. * string_from_array(): -- (style=insert): change the two "if" statements to if/elseif, where the "NULL" value doesn't have single quotes around it. /cs_phpDB.class.php: * run_update(): -- capture error if one exists -- throw a different exception on error. Modified Paths: -------------- trunk/1.0/cs_globalFunctions.class.php trunk/1.0/cs_phpDB.class.php Modified: trunk/1.0/cs_globalFunctions.class.php =================================================================== --- trunk/1.0/cs_globalFunctions.class.php 2009-07-20 21:57:33 UTC (rev 409) +++ trunk/1.0/cs_globalFunctions.class.php 2009-07-21 03:21:21 UTC (rev 410) @@ -54,6 +54,9 @@ $newSetting = 0; } } + elseif(!is_bool($newSetting) && is_bool($this->oldForceSqlQuotes)) { + $newSetting = $this->oldForceSqlQuotes; + } else { throw new exception(__METHOD__ .": invalid new setting (". $newSetting .")"); } @@ -191,14 +194,14 @@ foreach($array as $key=>$value) { @$tmp[0] = $this->create_list($tmp[0], $key); //clean the string, if required. - if($cleanString) { + if(is_null($value)) { + $value = "NULL"; + } + elseif($cleanString) { //make sure it's not full of poo... $value = $this->cleanString($value, "sql"); #$value = "'". $value ."'"; } - if((is_null($value)) OR ($value == "")) { - $value = "NULL"; - } @$tmp[1] = $this->create_list($tmp[1], $value, ",", 1); } Modified: trunk/1.0/cs_phpDB.class.php =================================================================== --- trunk/1.0/cs_phpDB.class.php 2009-07-20 21:57:33 UTC (rev 409) +++ trunk/1.0/cs_phpDB.class.php 2009-07-21 03:21:21 UTC (rev 410) @@ -165,9 +165,13 @@ public function run_update($sql, $zeroIsOk=false) { $this->exec($sql); + $dberror = $this->errorMsg(); $numAffected = $this->numAffected(); - if($numAffected==0 && $zeroIsOk == false) { + if(strlen($dberror)) { + throw new exception(__METHOD__ .": error while running update::: ". $dberror ." -- SQL::: ". $sql); + } + elseif($numAffected==0 && $zeroIsOk == false) { throw new exception(__METHOD__ .": no rows updated (". $numAffected ."), SQL::: ". $sql); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |