[Mapbender-commits] r1592 - trunk/mapbender/http/php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Aug 6 04:08:52 EDT 2007


Author: christoph
Date: 2007-08-06 04:08:51 -0400 (Mon, 06 Aug 2007)
New Revision: 1592

Modified:
   trunk/mapbender/http/php/database-mysql.php
   trunk/mapbender/http/php/database-pgsql.php
Log:
replaced old string functions by multibyte string function

added exceptions

Modified: trunk/mapbender/http/php/database-mysql.php
===================================================================
--- trunk/mapbender/http/php/database-mysql.php	2007-08-06 08:05:15 UTC (rev 1591)
+++ trunk/mapbender/http/php/database-mysql.php	2007-08-06 08:08:51 UTC (rev 1592)
@@ -144,7 +144,7 @@
 		//if we haven't yet done an insert/update, 
 		//read from the read-only db
 		//
-		if (!$sys_db_is_dirty && eregi("^( )*(select)",$qstring)) {
+		if (!$sys_db_is_dirty && mb_eregi("^( )*(select)",$qstring)) {
 			if ($QUERY_COUNT%3==0) {
 				// 1/3rd of read queries go to master for now
 				return @mysql_db_query($sys_dbname,$qstring,$conn_update);
@@ -187,9 +187,9 @@
 		else{
 			$tmp .= "NULL";
 		}
-		$posa = strpos($qstring, $needle);
-		$posb = strlen($needle);
-		$qstring = substr($qstring,0,$posa).$tmp.substr($qstring,($posa + $posb));	
+		$posa = mb_strpos($qstring, $needle);
+		$posb = mb_strlen($needle);
+		$qstring = mb_substr($qstring,0,$posa).$tmp.mb_substr($qstring,($posa + $posb));	
 	}
 	$r = db_query($qstring);
 	return $r;

Modified: trunk/mapbender/http/php/database-pgsql.php
===================================================================
--- trunk/mapbender/http/php/database-pgsql.php	2007-08-06 08:05:15 UTC (rev 1591)
+++ trunk/mapbender/http/php/database-pgsql.php	2007-08-06 08:08:51 UTC (rev 1592)
@@ -159,11 +159,14 @@
 			else{
 				$tmp .= "NULL";
 			}
-			$posa = strpos($qstring, $needle);
-			$posb = strlen($needle);
-			$qstring = substr($qstring,0,$posa).$tmp.substr($qstring,($posa + $posb));	
+			$posa = mb_strpos($qstring, $needle);
+			$posb = mb_strlen($needle);
+			$qstring = mb_substr($qstring,0,$posa).$tmp.mb_substr($qstring,($posa + $posb));	
 		}
 		$r = db_query($qstring);
+		if(!$r){
+			$e = new mb_exception("Error while executing sql statement in ".$_SERVER['SCRIPT_FILENAME'].": Sql: ".$qstring.", Error: ".db_error());
+		}
 	}
 	else{
 		$result = pg_prepare("", $qstring);



More information about the Mapbender_commits mailing list