[Mapbender-commits] r7005 - branches/mapbender/lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Sat Oct 2 09:53:31 EDT 2010


Author: christoph
Date: 2010-10-02 13:53:31 +0000 (Sat, 02 Oct 2010)
New Revision: 7005

Modified:
   branches/mapbender/lib/database-pgsql-pdo.php
Log:
removed obsolete code

Modified: branches/mapbender/lib/database-pgsql-pdo.php
===================================================================
--- branches/mapbender/lib/database-pgsql-pdo.php	2010-10-02 13:53:13 UTC (rev 7004)
+++ branches/mapbender/lib/database-pgsql-pdo.php	2010-10-02 13:53:31 UTC (rev 7005)
@@ -18,33 +18,11 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 /**
- * \file
- * \brief MySQL database connection/querying layer
- * 
- * MySQL database connection/querying layer
- *
- * example:
- * \code
- * include_once(dirname(__FILE__)."/afwphp/database-mysql.php");  
- * $sys_dbhost=...                            
- * $sys_dbuser=...                            
- * $sys_dbpasswd=...                           
- * $sys_dbname=...                            
- *                                             
- * db_connect();                               
- * ...                                         
- * $rs = db_query("select * from table");      
- * while($row = db_fetch_array($rs));
- *  ...
- * \endcode
- */
-
-/**
  * System-wide database type
  *
  * @var	constant		$sys_database_type
  */
-$sys_database_type='pgsql';
+$sys_database_type='pgsql-pdo';
 
 /**
  *  Connect to the database
@@ -63,64 +41,9 @@
 
 function db_connect($DBSERVER="",$OWNER="",$PW="") {
 	return Mapbender::db();
-/*
-	global $sys_dbhost,$sys_dbuser,$sys_dbpasswd,$sys_dbname,$db_debug;
-	global $conn,$conn_update,$DB;	
-
-	
-	$db_debug=0;
-	if ($DBSERVER)
-		$sys_dbhost = $DBSERVER; 
-	if ($OWNER)
-		$sys_dbuser = $OWNER; 
-	if ($PW && $PW != null)
-		$sys_dbpasswd = $PW; 
-	
-	$sys_dbport = PORT; 	
-		
-	if($GLOBALS['DB'])
-		$sys_dbname = $DB;
-			
-	$connstring = "";
-	if ($sys_dbuser)		
-		$connstring.=" user=$sys_dbuser";
-	if ($sys_dbname)		
-		$connstring.=" dbname=$sys_dbname";		
-	if ($sys_dbhost)		
-		$connstring.=" host=$sys_dbhost";	
-	if ($sys_dbport)		
-		$connstring.=" port=$sys_dbport";		
-	if ($sys_dbpasswd)		
-		$connstring.=" password=$sys_dbpasswd";		
-	
-	if ($db_debug)
-		echo $connstring." ";		
-
-	$conn = pg_connect($connstring);		
-
-		#if(isset($sys_db_clientencoding) && $sys_db_clientencoding > "")
-		#{
-		#pg_set_client_encoding ( $conn, $sys_db_clientencoding);
-		#}
-	#return $conn;
-	if ($db_debug)
-		echo "conn=".$conn;
-#echo $connstring;
-#if(!$conn)
-#{echo "FEHLER in Connection";
-#pg_error($conn);}	
-	
-	return $conn;
- 
- */
 }
 
 function db_select_db($DB,$con="") {
-//	global $conn,$sys_dbname;
-#	$sys_dbname = DB;	
-#	$_con = $con ? $con : $conn;
-#	$ret = @mysql_select_db($sys_dbname,$_con);
-//	echo "$ret=@mysql_select_db($sys_dbname,$_con);";
 }
 
 /**
@@ -132,18 +55,6 @@
  */
 function db_query($qstring) {
 	return Mapbender::db()->query($qstring);
-/*
-	global $sys_dbhost,$sys_dbuser,$sys_dbpasswd,$sys_dbname,$db_debug,
-		$conn,$conn_update,$QUERY_COUNT,$DBSERVER,$OWNER,$PW,$DB;
-	$QUERY_COUNT++;
-	$ret = pg_exec($qstring);
-//	$e = new mb_exception("not ps:  ".$_SERVER['SCRIPT_FILENAME']." : ".$qstring);
-	if(!$ret){
-		$e = new mb_exception("db_query($qstring)=$ret db_error=".db_error());
-	}
-	return $ret;
-
- */
 }
 /**
  *  prepare and query the database
@@ -179,47 +90,6 @@
 		return false;
 	}
 	return $statement;
-
-/*
-	$orig_qstring = $qstring;
-	$ci = new checkInput($qstring,$params,$types);
-	$params = $ci->v; 
-	if(PREPAREDSTATEMENTS == false){
-		for ($i=0; $i<count($params); $i++){
-			$needle = "$".strval($i+1);
-			$tmp = '';
-			if($params[$i] !== NULL){
-				if($types[$i] == 's'){ $tmp .= "'"; }
-				$tmp .= $params[$i];
-				if($types[$i] == 's'){ $tmp .= "'"; }
-			}
-			else{
-				$tmp .= "NULL";
-			}
-			$posa = mb_strpos($qstring, $needle);
-			if(!$posa) { 
- 				$e = new mb_exception("Error while preparing statement in ".$_SERVER['SCRIPT_FILENAME']. ": Sql :". $orig_qstring .",Error: parameter '$needle' not found ");
- 			}
-			$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);
-		if(!$result){
-			$e = new mb_exception("Error while preparing statement in ".$_SERVER['SCRIPT_FILENAME'].": Sql: ".$qstring.", Error: ".db_error());
-		}
-		$r = pg_execute("", $params);
-		if(!$r){
-			$e = new mb_exception("Error while executing prepared statement in ".$_SERVER['SCRIPT_FILENAME'].": Sql: ".$qstring.", Error: ".db_error());
-		}
-	}	
-	return $r;
-*/
 }
 /**
  *	Begin a transaction
@@ -229,7 +99,6 @@
  */
 function db_begin() {
 	return Mapbender::db()->beginTransaction();
-//	return db_query("BEGIN WORK");
 }
 
 /**
@@ -240,7 +109,6 @@
  */
 function db_commit() {
 	return Mapbender::db()->commit();
-//	return db_query("COMMIT");
 }
 
 /**
@@ -251,12 +119,6 @@
  */
 function db_rollback() {
 	return Mapbender::db()->rollback();
-/*
-	$str = db_error();
-	db_query("ROLLBACK");
-	die('sql error: ' . $str . " ROLLBACK performed....");
-
- */
 }
 
 /**
@@ -266,15 +128,6 @@
  */
 function db_numrows($qhandle) {
 	return $qhandle->rowCount;
-/*
-	// return only if qhandle exists, otherwise 0
-	if ($qhandle) {
-		return @pg_numrows($qhandle);
-	} else {
-		return 0;
-	}
- *
- */
 }
 /**
  * Returns the number of rows in this result set
@@ -284,14 +137,6 @@
  */ 
 function db_num_rows($qhandle) {
 	return $qhandle->rowCount;
-/*
-	// return only if qhandle exists, otherwise 0
-	if ($qhandle) {
-		return @pg_num_rows($qhandle);
-	} else {
-		return 0;
-	}
- */
 }
 
 /**
@@ -300,7 +145,6 @@
  *  @param	$qhandle (string)	Query result set handle
  */
 function db_free_result($qhandle) {
-//	return @pg_freeresult($qhandle);
 }
 
 /**
@@ -312,9 +156,6 @@
  *  @param		$row (int)		Row number
  */
 function db_reset_result($qhandle,$row=0) {
-#dummy
-//	return 0;#mysql_data_seek($qhandle,$row);
-	
 }
 
 /**
@@ -327,7 +168,6 @@
 function db_result($qhandle,$row,$field) {
 	$arr = $qhandle->fetchAll();
 	return $arr[$row][$field];
-//	return @pg_result($qhandle,$row,$field);
 }
 
 /**
@@ -336,7 +176,6 @@
  *  @param		$lhandle (string)	Query result set handle
  */
 function db_numfields($lhandle) {
-//	return @pg_numfields($lhandle);
 }
 
 /**
@@ -347,7 +186,6 @@
  */
 function db_num_fields($lhandle) {
 	return $lhandle->columnCount();
-//	return @pg_num_fields($lhandle);
 }
 
 /**
@@ -357,7 +195,6 @@
  *  @param		$fnumber (int)	Column number
  */
 function db_fieldname($lhandle,$fnumber) {
-//	   return @pg_fieldname($lhandle,$fnumber);
 }
 
 /**
@@ -366,8 +203,6 @@
  *  @param		$qhandle (string)	Query result set handle
  */
 function db_affected_rows($qhandle) {
-	
-//	return @pg_cmdtuples($qhandle);
 }
 
 /**
@@ -381,7 +216,6 @@
  */
 function db_fetch_array($qhandle) {
 	return $qhandle->fetch(PDO::FETCH_BOTH);
-//	return @pg_fetch_array($qhandle);
 }
 /**                                                       
  * fetch a row into an associative array 
@@ -391,12 +225,9 @@
  */
 function db_fetch_assoc($qhandle) {
 	return $qhandle->fetch(PDO::FETCH_ASSOC);
-//	return @pg_fetch_assoc($qhandle);
-
 }
 function db_fetch_all($qhandle){
 	return $qhandle->fetchAll();
-//	return @pg_fetch_all($qhandle);
 }
 /**                                                       
  * fetch a row into an array 
@@ -406,7 +237,6 @@
  */
 function db_fetch_row($qhandle,$fnumber=0) {
 	return $qhandle->fetch(PDO::FETCH_BOTH);
-//	return pg_fetch_row($qhandle);
 }
 
 /**
@@ -423,14 +253,6 @@
     } else {
         return 0;
     }
-/*
-	$res=db_query("SELECT max($pkey_field_name) AS id FROM $table_name");
-    if ($res && db_numrows($res) > 0) {
-        return @db_result($res,0,'id');
-    } else {
-        return 0;
-    }
- */
 }
 
 
@@ -438,72 +260,12 @@
 
 function db_insert_id($qhandle="",$table_name="",$pkey_field_name="") {
 	return db_insertid($qhandle, $table_name, $pkey_field_name);
-/*
-	global $sys_dbhost,$sys_dbuser,$sys_dbpasswd,$sys_dbname,$db_debug,
-		$conn,$conn_update,$QUERY_COUNT,$DBSERVER,$OWNER,$PW,$DB;
-  $res=db_query("SELECT max($pkey_field_name) AS id FROM $table_name");
-    if ($res && db_numrows($res) > 0) {
-        return db_result($res,0,'id');
-    } else {
-        return 0;
-    }
- *
- */
 }
-/*
-function db_last_oid()
-      {
-      	global $sys_dbhost,$sys_dbuser,$sys_dbpasswd,$sys_dbname,$db_debug,
-		$conn,$conn_update,$QUERY_COUNT;
-        global $DBSERVER,$OWNER,$PW,$DB	;
-             return pg_getlastoid($conn);
-      }
-*/
 
 /**
  * Returns the last error from the database
  */
 function db_error() {
 	return implode(", ", Mapbender::db()->errorInfo());
-//	return @pg_last_error();
 }
-
-/**
- * Get the flags associated with the specified field in a result 
- *
- *  @param		$lhandle	(string) Query result set handle
- *  @param		$fnumber (int)	Column number
- *
- * 					Examples: "not_null", "primary_key", "unique_key", "multiple_key",					 
- *                    "blob", "unsigned", "zerofill","binary", "enum",                  
- *                    "auto_increment", "timestamp"                                     
- */
-/*
-function db_field_flags($lhandle,$fnumber) {
-	   print "db_field_flags()	isn't implemented";
-	   
-}
-*/
-/**                                                       
- * Get the type of the specified field  
- *
- *  @param		$lhandle	(string) Query result set handle
- *  @param		$fnumber (int)	Column number
- */                                                       
-/*
-function db_field_type($lhandle,$fnumber) {               
-	   return @pg_fieldtype($lhandle,$fnumber);         
-}                                                         
-*/
-/**                                                       
- * Get the length of the specified field                                                            
- *
- *  @param		$lhandle	(string) Query result set handle
- *  @param		$fnumber (int)	Column number
- */                                                       
-/*
-function db_field_len($lhandle,$fnumber) {               
-	   return @pg_fieldlen($lhandle,$fnumber);         
-} 
-*/
 ?>



More information about the Mapbender_commits mailing list