cvs: php4 /pear/DB storage.php

From: Date: Wed, 23 May 2001 12:38:20 +0000
Subject: cvs: php4 /pear/DB storage.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-180@lists.php.net to get a copy of this message
ssb Wed May 23 05:38:20 2001 EDT Modified files: /php4/pear/DB storage.php Log: * added DB_storage::delete() (as suggested by Wolfram Kriesing) * fixed some raiseError calls Index: php4/pear/DB/storage.php diff -u php4/pear/DB/storage.php:1.15 php4/pear/DB/storage.php:1.16 --- php4/pear/DB/storage.php:1.15 Wed May 16 23:57:37 2001 +++ php4/pear/DB/storage.php Wed May 23 05:38:20 2001 @@ -325,7 +325,8 @@ // only change if $property is known and object is not // read-only if ($this->_readonly) { - return $this->raiseError("object is read-only"); + return $this->raiseError(null, DB_WARNING_READ_ONLY, null, + null, null, null, true); } if (empty($this->_readonly) && isset($this->_properties[$property])) { if (empty($this->_validator)) { @@ -339,13 +340,15 @@ $this->$property = $newvalue; $this->_changes[$property]++; } else { - return $this->raiseError("invalid field: $property", null, - null, null, $newvalue); + return $this->raiseError(null, DB_ERROR_INVALID, null, + null, "invalid field: $property", + null, true); } return true; } - return $this->raiseError("unknown field: $property", null, null, - null, $newvalue); + return $this->raiseError(null, DB_ERROR_NOSUCHFIELD, null, + null, "unknown field: $property", + null, true); } /** @@ -402,6 +405,31 @@ $this->_changes = array(); } return DB_OK; + } + + /** + * Delete the row represented by this object from the database. + * + * @return mixed DB_OK or a DB error + */ + function delete() + { + if ($this->_readonly) { + return $this->raiseError(null, DB_WARNING_READ_ONLY, null, + null, null, null, true) + } + $query = 'DELETE FROM ' . $this->_table .' WHERE '. + $this->_makeWhere(); + $res = $this->query($query); + if (DB::isError($res)) { + return $res; + } + foreach ($this->_properties as $prop => $foo) { + unset($this->$prop); + } + $this->_properties = array(); + $this->_changes = array(); + return DB_OK; } }

« previous php.pear.cvs (#180) next »