View Issue Details

IDProjectCategoryView StatusLast Update
98PHPOF2Defaultpublic5 Jan 2009 16:33
Reportermrosenquist Assigned Totimj  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Target Version0.11.0Fixed in Version0.11.0 
Summary98: DBRow has no internal error checking for PEAR errors
DescriptionDBRow has no internal error checking results, PEAR::isError($res)
TagsNo tags attached.
Attached Files
DBRow.php.patch (2,474 bytes)   
--- DBRow.php	2008-09-19 10:23:11.000000000 +0100
+++ DBRow.php.error_checking	2008-09-19 10:22:06.000000000 +0100
@@ -222,6 +222,10 @@
 		$sql = 'SELECT ' . $this->fieldlist . ' FROM '.$this->table->name . ' WHERE ' . $this->getPrikeyWhereClause();
 		$res = $this->db->query ($sql);
 		
+		if (PEAR::isError($res)) {
+			throw new Exception ("MDB2 error when fetching row in table '".$this->table->name."': ".$res->getMessage());
+		}
+		
 		if ($res->numRows()> 1) {
 			throw new Exception ('PHPOF2_DBRow::get() called but primary key value ("' . $prikey_value . '") was not unique in table "' . $this->table->name . '"');
 		} else if ($res->numRows() > 0) {
@@ -270,6 +274,10 @@
 		
 		$res = $this->db->query ($sql);
 		
+		if (PEAR::isError($res)) {
+			throw new Exception ("MDB2 error when fetching unique in table '".$this->table->name."': ".$res->getMessage());
+		}
+		
 		if ($res->numRows() > 1) {
 			// The provided field/value pairs obviously weren't unique
 			throw new Exception ('More than one record retrieved by PHPOF2_DBRow::getUnique method');
@@ -518,6 +526,10 @@
 		
 		$res = $this->db->query($SQL);
 		
+		if (PEAR::isError($res)) {
+			throw new Exception ("MDB2 error when inserting row in table '".$this->table->name."': ".$res->getMessage());
+		}
+		
 		// Update the ID if only a single key and the key hasnot been set manualy
 		if (count($this->pri_keys) == 1 && $this->table->key_auto_increment && !isset($this->{$this->pri_keys[0]})) {
 			$this->{$this->pri_keys[0]} = $this->db->lastInsertId($this->table->name);
@@ -569,7 +581,12 @@
 				$insert_values[] = $this->db->quoteIdentifier($field).'='.$value;
 			}
 			$SQL = 'UPDATE '.$this->table->name.' SET '.implode(',',$insert_values).' WHERE ' . $this->getPrikeyWhereClause($this->_orig_prikey);
-			$this->db->query($SQL);			
+			$res = $this->db->query($SQL);
+			
+			if (PEAR::isError($res)) {
+				throw new Exception ("MDB2 error when updating row in table '".$this->table->name."': ".$res->getMessage());
+			}
+		
 		} else {
 			if (count($this->pri_keys) > 0) {
 				throw new Exception('PHPOF2_DBRow::Update() called, but the primary key is empty');
@@ -617,7 +634,11 @@
 				}
 			}
 			$sql .= implode(' AND ', $clauses);
-			$this->db->query($sql);
+			$res = $this->db->query($sql);
+			if (PEAR::isError($res)) {
+				throw new Exception ("MDB2 error when deleting row in table '".$this->table->name."': ".$res->getMessage());
+			}
+		
 		}
 		$this->clear();
 
DBRow.php.patch (2,474 bytes)   

Relationships

related to 97 closedtimj the optimized "tableDiscoverSchema" does not check for PEAR errors 

Activities

Issue History

Date Modified Username Field Change
19 Sep 2008 10:24 mrosenquist New Issue
19 Sep 2008 10:24 mrosenquist File Added: DBRow.php.patch
19 Sep 2008 10:28 timj Target Version => 0.10.2
21 Dec 2008 22:28 timj Target Version 0.10.2 => 0.11.0
21 Dec 2008 22:28 timj Status new => assigned
21 Dec 2008 22:28 timj Assigned To => timj
29 Dec 2008 17:07 timj Target Version 0.11.0 =>
29 Dec 2008 17:28 timj Relationship added related to 97
29 Dec 2008 18:52 timj Status assigned => resolved
29 Dec 2008 18:52 timj Resolution open => fixed
29 Dec 2008 18:52 timj Fixed in Version => 0.11.0
29 Dec 2008 18:52 timj Target Version => 0.11.0
29 Dec 2008 18:52 timj Summary DBRow has no internal error checking results, PEAR::isError($res) => DBRow has no internal error checking for PEAR errors
5 Jan 2009 16:33 timj Status resolved => closed