svn commit: r332 - trunk/mapbender/http/php/database-mysql.php

uli at osgeo.org uli at osgeo.org
Tue May 23 10:48:42 EDT 2006


Author: uli
Date: 2006-05-23 14:48:42+0000
New Revision: 332

Modified:
   trunk/mapbender/http/php/database-mysql.php

Log:
checkInput included

Modified: trunk/mapbender/http/php/database-mysql.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/php/database-mysql.php?view=diff&rev=332&p1=trunk/mapbender/http/php/database-mysql.php&p2=trunk/mapbender/http/php/database-mysql.php&r1=331&r2=332
==============================================================================
--- trunk/mapbender/http/php/database-mysql.php	(original)
+++ trunk/mapbender/http/php/database-mysql.php	2006-05-23 14:48:42+0000
@@ -54,6 +54,7 @@
  *  in other functions in this library
  */
 include_once("../../http/classes/class_mb_exception.php");
+include_once("../../http/classes/class_checkInput.php");
 function db_escapestring($unescaped_string){
 	return @mysql_escape_string($unescaped_string);
 }
@@ -165,21 +166,19 @@
  *  @param		$types (array string types)		
  */
 function db_prep_query($qstring, $params, $types){
-	if(is_array($params) == false){
-		$params = array($params);
-	}
-	if(is_array($types) == false){
-		$types = array($types);
-	}
-	if(count($params) != count($types)){
-		$e = new mb_exception("array params and array types have a different count! Sql: ".$qstring);
-	}
+	$ci = new checkInput($qstring,$params,$types);
+	$params = $ci->v; 
 	for ($i=0; $i<count($params); $i++){
 		$needle = "$".strval($i+1);
 		$tmp = '';
-		if($types[$i] == 's'){ $tmp .= "'"; }
-		$tmp .= $params[$i];
-		if($types[$i] == 's'){ $tmp .= "'"; }
+		if($params[$i] !== NULL){
+			if($types[$i] == 's'){ $tmp .= "'"; }
+			$tmp .= $params[$i];
+			if($types[$i] == 's'){ $tmp .= "'"; }
+		}
+		else{
+			$tmp .= "NULL";
+		}
 		$posa = strpos($qstring, $needle);
 		$posb = strlen($needle);
 		$qstring = substr($qstring,0,$posa).$tmp.substr($qstring,($posa + $posb));	
@@ -214,7 +213,9 @@
  * may cause unexpected behavior in databases that don't
  */
 function db_rollback() {
-	return db_query("ROLLBACK");
+	$str = db_error();
+	db_query("ROLLBACK");
+	die('sql error: ' . $str . " ROLLBACK performed....");
 }
 
 /**




More information about the Mapbender_commits mailing list