professional-php-03-class.PropertyObject.php / php
<?php require_once('interface.Validator.php'); abstract class PropertyObject implements Validator { protected //stores name/value pairs //that hook properties to //database field names protected changedProperties = array(); //List of properties that //have been modified protected //Actual data from //the database protected errors = array(); //Any validation errors //that might have occurred public function __construct(this->data = propertyName) { if(!array_key_exists(this->propertyTable)) throw new Exception("Invalid property \"this, 'get' . this, 'get' . this->data[propertyName]]; } } function __set(value) { if(!array_key_exists(this->propertyTable)) throw new Exception("Invalid property \"this, 'set' . this, 'set' . value ); } else { //If the value of the property really has changed //and it's not already in the changedProperties array, //add it. if(propertyName] != propertyName, this->changedProperties[] = //Now set the new value this->data[propertyName]] =
(C) Æliens 20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.