cvs: php4 /pear/DB storage.php

From: Date: Sun, 15 Jul 2001 22:51:42 +0000
Subject: cvs: php4 /pear/DB storage.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-277@lists.php.net to get a copy of this message
ssb Sun Jul 15 18:51:42 2001 EDT Modified files: /php4/pear/DB storage.php Log: (PEAR DB_storage) fixed validation bug Index: php4/pear/DB/storage.php diff -u php4/pear/DB/storage.php:1.18 php4/pear/DB/storage.php:1.19 --- php4/pear/DB/storage.php:1.18 Thu May 31 03:38:06 2001 +++ php4/pear/DB/storage.php Sun Jul 15 18:51:42 2001 @@ -29,6 +29,8 @@ * you add, delete and change rows without using SQL. * * @author Stig Bakken <stig@php.net> + * + * @package DB */ class DB_storage extends PEAR { @@ -65,21 +67,27 @@ /** * Constructor * - * @param string the name of the database table + * @param $table string the name of the database table * - * @param mixed string with name of key column, or array of + * @param $keycolumn mixed string with name of key column, or array of * strings if the table has a primary key of more than one column * - * @param object database connection object + * @param $dbh object database connection object + * + * @param $validator mixed function or method used to validate + * each new value, called with three parameters: the name of the + * field/column that is changing, a reference to the new value and + * a reference to this object * */ - function DB_storage($table, $keycolumn, &$dbh) + function DB_storage($table, $keycolumn, &$dbh, $validator = null) { $this->PEAR('DB_Error'); $this->_table = $table; $this->_keycolumn = $keycolumn; $this->_dbh = $dbh; $this->_readonly = false; + $this->_validator = $validator; } /** @@ -87,6 +95,8 @@ * the table. * * XXX future improvement: use rowids? + * + * @access private */ function _makeWhere($keyval = null) { @@ -128,7 +138,7 @@ * Method used to initialize a DB_storage object from the * configured table. * - * @param $keyval the key[s] of the row to fetch (string or array) + * @param $keyval mixed the key[s] of the row to fetch (string or array) * * @return int DB_OK on success, a DB error if not */ @@ -332,7 +342,7 @@ if (empty($this->_validator)) { $valid = true; } else { - $valid = @call_user_func($this->validator, + $valid = @call_user_func($this->_validator, &$this->$property, &$newvalue, &$this); }

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