Location: PHPKode > scripts > Scrubs > scrubs/BaseObject.php
<?php

/**
 * 
 *
 * @version $Id$
 * @copyright 2003 
 **/

define('SCRUBS', dirname(dirname(__FILE__)));
 
include_once(SCRUBS.'/lib/Configer.php');

class BaseObject {

	var	$table          = "";
	var	$primaryKey     = "";
	var $className      = "";
	var	$autoIncrement  = true;
	var $newRecord      = true;
	var $oneToMany      = array();
	var $objectArrayMap = array();
	var $manyToOne      = array();
	var	$fields         = array();
	
	function BaseObject() {
		$this->className = get_class($this);
		$this->configure();
	}
	
	function configure() {
		$iniFile = dirname(dirname(__FILE__))."/config/".$this->className.".properties";
		$c  = new Configer($iniFile, true);
		$cr = $c->getSection("class");		
		$fr = $c->getSection("fields");
		$rr = $c->getSection("relationships");

		$this->table         = $cr['table'];
		$this->primaryKey    = $cr['primaryKey'];
		$this->autoIncrement = $cr['autoIncrement'];
		
		foreach($fr as $field => $property) {
			$this->fields[$field] = $property;
		}
		
		if (!empty($rr)) {
			foreach($rr as $relationship => $type) {
				$tr = $c->getSection($relationship);
				$this->objectArrayMap[$relationship] = $tr['objectArray'];
				if ($type == "oneToMany") {
					$this->oneToMany[$relationship] = $tr['linkOn'];
				} else {		
					$this->manyToOne[$relationship] = $tr['linkOn'];
				}
			}		
		}
	}
	
	function setNewRecord($_newRecord) {
		$this->newRecord = $_newRecord;
	}
}

?>
Return current item: Scrubs