Location: PHPKode > projects > Scorpio Framework for PHP > scorpioframework_php_0.3.5/libraries/generator/templates/dao/default.tpl
{*
Template contains the following keys:

'appAuthor' -> the application author
'appCopyright' -> application copyright notice
'classBaseString' -> the prefix for the class (database name canonised)
'database' -> the database this table is in
'exceptionClass' -> name of the exception to class to throw on error
'oConfig' -> full base config
'className' -> our intended class name
'primaryKey' -> array of fields that make up the primary key
'uniqueKeys' -> array of unique indexes containing the fields that make the key
'uniqueKeyFields' -> array of unqiue fields from all unique indexes
'nonUniqueFields' -> array of fields NOT in any unique or primary keys
'oTableDefinition' -> the full table definition object
'textUtil' -> text transform utility class
'hasUpdateField' -> set if the table has a field named updateDate

Generator uses { & } as a Smarty var
*}
{'<?php'}
/**
 * {$className}
 *
 * Stored in {$className}.class.php
 *
 * @author {$appAuthor}
 * @copyright {$appCopyright}
 * @package {$classBaseString}
 * @subpackage {$className}
 * @category {$className}
 * @version $Rev: 643 $
 */


/**
 * {$className} Class
 *
 * Provides access to records in {$database}.{$oTableDefinition->getTableName()}
 *
 * Creating a new record:
 * <code>
 * $o{$textUtil->classify($className)} = new {$className}();
{foreach name=example item=oField from=$oTableDefinition->getFields()}
 * $o{$textUtil->classify($className)}->set{$textUtil->CamelText($oField->getField())}($in{$textUtil->CamelText($oField->getField())});
{/foreach}
 * $o{$textUtil->classify($className)}->save();
 * </code>
 *
 * Accessing a record by primary key on constructor:
 * <code>
 * $o{$textUtil->classify($className)} = new {$className}({if count($primaryKey) > 0}{foreach name=construct key=seqID item=field from=$primaryKey}$in{$textUtil->CamelText($field->getColumnName())}{if !$smarty.foreach.construct.last}, {/if}{/foreach}{/if});
 * </code>
 *
{if count($primaryKey) > 0}
 * Access by manually calling load:
 * <code>
 * $o{$textUtil->classify($className)} = new {$className}();
{foreach key=seqID item=field from=$primaryKey}
 * $o{$textUtil->classify($className)}->set{$textUtil->CamelText($field->getColumnName())}($in{$textUtil->CamelText($field->getColumnName())});
{/foreach}
 * $o{$textUtil->classify($className)}->load();
 * </code>
{/if}
 *
 * Accessing a record by instance:
 * <code>
 * $o{$textUtil->classify($className)} = {$className}::getInstance({include file='primaryKeyMethodParameters.tpl'});
 * </code>
 * If there are other unique keys, separate methods should exist for each key.
 *
 * @package {$classBaseString}
 * @subpackage {$className}
 * @category {$className}
 */
class {$className} implements systemDaoInterface, systemDaoValidatorInterface {

	/**
	 * Container for static instances of {$className}
	 *
	 * @var array
	 * @access protected
	 * @static
	 */
	protected static $_Instances = array();

	/**
	 * Stores $_Modified
	 *
	 * @var boolean
	 * @access protected
	 */
	protected $_Modified = false;
{foreach name=properties item=oField from=$oTableDefinition->getFields()}

	/**
	 * Stores $_{$textUtil->CamelText($oField->getField())}
	 *
	 * @var {$oField->getPhpType()} {if count($oField->getValues()) > 0}({foreach key=key item=value from=$oField->getValues()}{$oField->getField()|upper}_{$value|upper|regex_replace:'/\W/':'_'},{/foreach}){/if}

	 * @access protected
	 */
	protected $_{$textUtil->CamelText($oField->getField())};
{if count($oField->getValues()) > 0}
{foreach key=key item=value from=$oField->getValues()}
	const {$oField->getField()|upper}_{$value|upper|regex_replace:'/\W/':'_'} = '{$value}';
{/foreach}
{/if}
{/foreach}

	/**
	 * If true, the object is scheduled to be deleted
	 *
	 * @var boolean
	 * @access protected
	 */
	protected $_MarkForDeletion = false;



	/**
	 * Returns a new instance of {$className}
	 *
{if count($primaryKey) > 0}
{foreach name=construct key=seqID item=field from=$primaryKey}
	 * @param {assign var=oField value=$oTableDefinition->getField($field->getColumnName())}{$oField->getPhpType()} $in{$textUtil->CamelText($oField->getField())}
{/foreach}
{/if}
	 * @return {$className}
	 */
	function __construct({include file='primaryKeyMethodParameters.tpl' setNull=true}) {
		$this->reset();
{if count($primaryKey) > 0}
		if ( {foreach name=construct key=seqID item=field from=$primaryKey}$in{$textUtil->CamelText($field->getColumnName())} !== null{if !$smarty.foreach.construct.last} && {/if}{/foreach} ) {
{foreach key=seqID item=field from=$primaryKey}
			$this->set{$textUtil->CamelText($field->getColumnName())}($in{$textUtil->CamelText($field->getColumnName())});
{/foreach}
			$this->load();
		}
{/if}
		return $this;
	}

	/**
	 * Creates a new {$className} containing non-unique properties
	 *
{foreach name=factory item=field from=$nonUniqueFields}
	 * @param {$field->getPhpType()} $in{$textUtil->CamelText($field->getField())}
{/foreach}
	 * @return {$className}
	 * @static
	 */
	public static function factory({foreach name=factory item=field from=$nonUniqueFields}$in{$textUtil->CamelText($field->getField())} = null{if !$smarty.foreach.factory.last}, {/if}{/foreach}) {
		$oObject = new {$className};
{foreach name=factory item=field from=$nonUniqueFields}
		if ( $in{$textUtil->CamelText($field->getField())} !== null ) {
			$oObject->set{$textUtil->CamelText($field->getField())}($in{$textUtil->CamelText($field->getField())});
		}
{/foreach}
		return $oObject;
	}

	/**
	 * Get an instance of {$className} by primary key
	 *
{if count($primaryKey) > 0}
{foreach name=construct key=seqID item=field from=$primaryKey}
	 * @param {assign var=oField value=$oTableDefinition->getField($field->getColumnName())}{$oField->getPhpType()} $in{$textUtil->CamelText($oField->getField())}
{/foreach}
{/if}
	 * @return {$className}
	 * @static
	 */
	public static function getInstance({include file='primaryKeyMethodParameters.tpl'}) {
		/**
		 * Check for an existing instance
		 */
{if count($primaryKey) > 0}
		if ( isset(self::$_Instances[{foreach name=factory key=seqID item=field from=$primaryKey}$in{$textUtil->CamelText($field->getColumnName())}{if !$smarty.foreach.factory.last}.'.'.{/if}{/foreach}]) ) {
			return self::$_Instances[{foreach name=factory key=seqID item=field from=$primaryKey}$in{$textUtil->CamelText($field->getColumnName())}{if !$smarty.foreach.factory.last}.'.'.{/if}{/foreach}];
		}

		/**
		 * No instance, create one
		 */
		$oObject = new {$className}();
{foreach key=seqID item=field from=$primaryKey}
		$oObject->set{$textUtil->CamelText($field->getColumnName())}($in{$textUtil->CamelText($field->getColumnName())});
{/foreach}
		if ( $oObject->load() ) {
			self::$_Instances[{foreach name=factory key=seqID item=field from=$primaryKey}$in{$textUtil->CamelText($field->getColumnName())}{if !$smarty.foreach.factory.last}.'.'.{/if}{/foreach}] = $oObject;
			return $oObject;
		}
{else}
		$oObject = new {$className}();
{/if}
		return $oObject;
	}
{if count($uniqueKeys) > 0}
{foreach name=uniqueKeys key=indexName item=fields from=$uniqueKeys}
{if $indexName != 'PRIMARY'}

	/**
	 * Get instance of {$className} by unique key ({$indexName})
	 *
{foreach name=keyParams item=field from=$fields}
	 * @param {assign var=oField value=$oTableDefinition->getField($field->getColumnName())}{$oField->getPhpType()} $in{$textUtil->CamelText($oField->getField())}
{/foreach}
	 * @return {$className}
	 * @static
	 */
	public static function getInstanceBy{$textUtil->CamelText($indexName)}({foreach name=keyParams item=field from=$fields}$in{$textUtil->CamelText($field->getColumnName())}{if !$smarty.foreach.keyParams.last}, {/if}{/foreach}) {
		/**
		 * Check for an existing instance
		 */
		if ( isset(self::$_Instances[{foreach name=keyParams key=seqID item=field from=$fields}$in{$textUtil->CamelText($field->getColumnName())}{if !$smarty.foreach.keyParams.last}.'.'.{/if}{/foreach}]) ) {
			return self::$_Instances[{foreach name=keyParams key=seqID item=field from=$fields}$in{$textUtil->CamelText($field->getColumnName())}{if !$smarty.foreach.keyParams.last}.'.'.{/if}{/foreach}];
		}

		/**
		 * No instance, create one
		 */
		$oObject = new {$className}();
{foreach key=seqID item=field from=$fields}
		$oObject->set{$textUtil->CamelText($field->getColumnName())}($in{$textUtil->CamelText($field->getColumnName())});
{/foreach}
		if ( $oObject->load() ) {
			self::$_Instances[{foreach name=keyParams key=seqID item=field from=$fields}$in{$textUtil->CamelText($field->getColumnName())}{if !$smarty.foreach.keyParams.last}.'.'.{/if}{/foreach}] = $oObject;
		}
		return $oObject;
	}
{/if}
{/foreach}
{/if}

	/**
	 * Returns an array of objects of {$className}
	 *
	 * @param integer $inOffset
	 * @param integer $inLimit
	 * @return array
	 * @static
	 */
	public static function listOfObjects($inOffset = null, $inLimit = 30) {
		$query = 'SELECT * FROM '.system::getConfig()->getDatabase('{$database}').'.{$oTableDefinition->getTableName()}';
		if ( $inOffset !== null ) {
			$query .= ' LIMIT '.$inOffset.','.$inLimit;
		}

		$list = array();
		try {
			$oStmt = dbManager::getInstance()->prepare($query);
			if ( $oStmt->execute() ) {
				foreach ( $oStmt as $row ) {
					$oObject = new {$className}();
					$oObject->loadFromArray($row);
					$list[] = $oObject;
				}
			}
			$oStmt->closeCursor();
		} catch ( Exception $e ) {
			systemLog::error($e->getMessage());
			throw $e;
		}
		return $list;
	}



	/**
	 * Loads a record from the database based on the primary key or first unique index
	 *
	 * @return boolean
	 */
	function load() {
		$return = false;
		$query = '
			SELECT {assign var=oFieldSet value=$oTableDefinition->getFields()}{foreach name=load item=oField from=$oFieldSet}{$oField->getField()}{if $smarty.foreach.load.iteration != $oFieldSet->countFields()}, {/if}{/foreach}

			  FROM '.system::getConfig()->getDatabase('{$database}').'.{$oTableDefinition->getTableName()}';

		$where = array();
{if count($uniqueKeyFields) > 0}
{foreach name=load item=keyIndex from=$uniqueKeyFields}
		if ( $this->_{$textUtil->CamelText($keyIndex->getColumnName())} !== {assign var=oField value=$oTableDefinition->getField($keyIndex->getColumnName())}{if $oField->getIsNull()}null{elseif is_array($oField->getDefault())}array(){elseif is_float($oField->getDefault())}0.{string_repeat char=0 repeat=$oField->getPrecision()|default:1}{elseif is_numeric($oField->getDefault())}0{elseif is_string($oField->getDefault())}{if count($oField->getValues()) > 0}'{$oField->getDefault()}'{else}''{/if}{else}false{/if} ) {
			$where[] = ' {$keyIndex->getColumnName()} = :{$textUtil->CamelText($keyIndex->getColumnName())} ';
		}
{/foreach}
{else}
{foreach name=load item=oField from=$oTableDefinition->getFields()}
		if ( $this->_{$textUtil->CamelText($oField->getField())} !== {include file='defaultFieldValue.tpl' oField=$oField} ) {
			$where[] = ' {$oField->getField()} = :{$textUtil->CamelText($oField->getField())} ';
		}
{/foreach}
{/if}

		if ( count($where) == 0 ) {
			return false;
		}

		$query .= ' WHERE '.implode(' AND ', $where);

		try {
			$oStmt = dbManager::getInstance()->prepare($query);
{if count($uniqueKeyFields) > 0}
{foreach name=load item=keyIndex from=$uniqueKeyFields}
			if ( $this->_{$textUtil->CamelText($keyIndex->getColumnName())} !== {assign var=oField value=$oTableDefinition->getField($keyIndex->getColumnName())}{if $oField->getIsNull()}null{elseif is_array($oField->getDefault())}array(){elseif is_float($oField->getDefault())}0.{string_repeat char=0 repeat=$oField->getPrecision()|default:1}{elseif is_numeric($oField->getDefault())}0{elseif is_string($oField->getDefault())}{if count($oField->getValues()) > 0}'{$oField->getDefault()}'{else}''{/if}{else}false{/if} ) {
				$oStmt->bindValue(':{$textUtil->CamelText($keyIndex->getColumnName())}', $this->_{$textUtil->CamelText($keyIndex->getColumnName())});
			}
{/foreach}
{else}
{foreach name=load item=oField from=$oTableDefinition->getFields()}
			if ( $this->_{$textUtil->CamelText($oField->getField())} !== {if $oField->getIsNull()}null{elseif is_array($oField->getDefault())}array(){elseif is_float($oField->getDefault())}0.{string_repeat char=0 repeat=$oField->getPrecision()|default:1}{elseif is_numeric($oField->getDefault())}0{elseif is_string($oField->getDefault())}{if count($oField->getValues()) > 0}'{$oField->getDefault()}'{else}''{/if}{else}false{/if} ) {
				$oStmt->bindValue(':{$textUtil->CamelText($oField->getField())}', $this->_{$textUtil->CamelText($oField->getField())});
			}
{/foreach}
{/if}

			$this->reset();
			if ( $oStmt->execute() ) {
				$row = $oStmt->fetch();
				if ( $row !== false && is_array($row) ) {
					$this->loadFromArray($row);
					$oStmt->closeCursor();
					$return = true;
				}
			}
		} catch ( Exception $e ) {
			systemLog::error($e->getMessage());
			throw $e;
		}
		return $return;
	}

	/**
	 * Loads a record by array
	 *
	 * @param array $inArray
	 */
	function loadFromArray($inArray) {
{foreach name=properties item=oField from=$oTableDefinition->getFields()}
		$this->set{$textUtil->CamelText($oField->getField())}({if $oField->getPhpType() == 'integer'}(int){/if}$inArray['{$oField->getField()}']);
{/foreach}
		$this->setModified(false);
	}

	/**
	 * Saves object to the table
	 *
	 * @return boolean
	 */
	function save() {
		$return = false;
		if ( $this->isModified() ) {
			$message = '';
			if ( !$this->isValid($message) ) {
				throw new {$exceptionClass}($message);
			}
{if $hasUpdateField}
			$this->setUpdateDate(date(system::getConfig()->getDatabaseDatetimeFormat()));
{/if}
			if ( $this->_Modified ) {
				$query = '
				INSERT INTO '.system::getConfig()->getDatabase('{$database}').'.{$oTableDefinition->getTableName()}
					( {assign var=oFieldSet value=$oTableDefinition->getFields()}{foreach name=save item=oField from=$oFieldSet}{$oField->getField()}{if $smarty.foreach.save.iteration != $oFieldSet->countFields()}, {/if}{/foreach})
				VALUES
					({foreach name=save item=oField from=$oFieldSet}:{$textUtil->CamelText($oField->getField())}{if $smarty.foreach.save.iteration != $oFieldSet->countFields()}, {/if}{/foreach})
{if count($nonUniqueFields) > 0}
				ON DUPLICATE KEY UPDATE
{foreach name=nonunique item=field from=$nonUniqueFields}
					{$field->getField()}=VALUES({$field->getField()}){if !$smarty.foreach.nonunique.last},
{/if}
{/foreach}
{/if}';

				try {
					$oDB = dbManager::getInstance();
					$oStmt = $oDB->prepare($query);
{foreach name=save item=field from=$oTableDefinition->getFields()}
					$oStmt->bindValue(':{$textUtil->CamelText($field->getField())}', $this->_{$textUtil->CamelText($field->getField())});
{/foreach}

					if ( $oStmt->execute() ) {
{if count($primaryKey) == 1}
{foreach name=load key=seqID item=index from=$primaryKey}
						if ( !$this->get{$textUtil->CamelText($index->getColumnName())}() ) {
							$this->set{$textUtil->CamelText($index->getColumnName())}($oDB->lastInsertId());
						}
{/foreach}
{/if}
						$this->setModified(false);
						$return = true;
					}
				} catch ( Exception $e ) {
					systemLog::error($e->getMessage());
					throw $e;
				}
			}
		}
		return $return;
	}

	/**
	 * Deletes the object from the table
	 *
	 * @return boolean
	 */
	function delete() {
		$query = '
			DELETE FROM '.system::getConfig()->getDatabase('{$database}').'.{$oTableDefinition->getTableName()}
			WHERE
{foreach name=load key=seqID item=index from=$primaryKey}
				{$index->getColumnName()} = :{$textUtil->CamelText($index->getColumnName())}{if !$smarty.foreach.load.last} AND
{/if}
{/foreach}

			LIMIT 1';

		try {
			$oStmt = dbManager::getInstance()->prepare($query);
{foreach name=load key=seqID item=index from=$primaryKey}
			$oStmt->bindValue(':{$textUtil->CamelText($index->getColumnName())}', $this->_{$textUtil->CamelText($index->getColumnName())});
{/foreach}

			if ( $oStmt->execute() ) {
				$oStmt->closeCursor();
				$this->reset();
				return true;
			}
		} catch ( Exception $e ) {
			systemLog::error($e->getMessage());
			throw $e;
		}
		return false;
	}

	/**
	 * Resets object properties to defaults
	 *
	 * @return {$className}
	 */
	function reset() {
{foreach name=properties item=oField from=$oTableDefinition->getFields()}
		$this->_{$textUtil->CamelText($oField->getField())} = {include file='defaultFieldValue.tpl'};
{/foreach}
		$this->setModified(false);
		$this->setMarkForDeletion(false);
		return $this;
	}

	/**
	 * Returns object as a string with each property separated by $newLine
	 *
	 * @param string $newLine
	 * @return string
	 */
	function toString($newLine = "\n") {
		$string  = '';
{foreach name=properties item=oField from=$oTableDefinition->getFields()}
		$string .= " {$textUtil->CamelText($oField->getField())}[$this->_{$textUtil->CamelText($oField->getField())}] $newLine";
{/foreach}
		return $string;
	}

	/**
	 * Returns object as XML with each property separated by $newLine
	 *
	 * @param string $newLine
	 * @return string
	 */
	function toXml($newLine = "\n") {
		$className = '{$className}';
		$xml  = "<$className>$newLine";
{foreach name=properties item=oField from=$oTableDefinition->getFields()}
		$xml .= "\t<property name=\"{$textUtil->CamelText($oField->getField())}\" value=\"$this->_{$textUtil->CamelText($oField->getField())}\" type=\"{$oField->getPhpType()}\" /> $newLine";
{/foreach}
		$xml .= "</$className>$newLine";
		return $xml;
	}

	/**
	 * Returns properties of object as an array
	 *
	 * @return array
	 */
	function toArray() {
		return get_object_vars($this);
	}



	/**
	 * Returns true if object is valid
	 *
	 * @return boolean
	 */
	function isValid(&$message = '') {
		$valid = true;
{foreach name=properties item=oField from=$oTableDefinition->getFields()}
		if ( $valid ) {
			$valid = $this->check{$textUtil->CamelText($oField->getField())}($message);
		}
{/foreach}
		return $valid;
	}
{foreach name=properties item=oField from=$oTableDefinition->getFields()}

	/**
	 * Checks that $_{$textUtil->CamelText($oField->getField())} has a valid value
	 *
	 * @return boolean
	 * @access protected
	 */
	protected function check{$textUtil->CamelText($oField->getField())}(&$inMessage = '') {
		$isValid = true;
{if $oField->getPhpType() == 'integer'}
		if ( !is_numeric($this->_{$textUtil->CamelText($oField->getField())}) && {if $oField->getIsNull()}$this->_{$textUtil->CamelText($oField->getField())} !== null && {/if}$this->_{$textUtil->CamelText($oField->getField())} !== 0 ) {
			$inMessage .= "{ldelim}$this->_{$textUtil->CamelText($oField->getField())}{rdelim} is not a valid value for {$textUtil->CamelText($oField->getField())}";
			$isValid = false;
		}
{elseif $oField->getPhpType() == 'float'}
		if ( !{if $oField->getPrecision() > 0}is_float{else}is_numeric{/if}($this->_{$textUtil->CamelText($oField->getField())}) && {if $oField->getIsNull()}$this->_{$textUtil->CamelText($oField->getField())} !== null && {/if}$this->_{$textUtil->CamelText($oField->getField())} !== 0{if $oField->getPrecision() > 0}.{string_repeat char=8 repeat=$oField->getPrecision()|default:1}{/if} ) {
			$inMessage .= "{ldelim}$this->_{$textUtil->CamelText($oField->getField())}{rdelim} is not a valid value for {$textUtil->CamelText($oField->getField())}";
			$isValid = false;
		}
{elseif $oField->getPhpType() == 'string'}
		if ( !is_string($this->_{$textUtil->CamelText($oField->getField())}) && {if $oField->getIsNull()}$this->_{$textUtil->CamelText($oField->getField())} !== null && {/if}$this->_{$textUtil->CamelText($oField->getField())} !== '' ) {
			$inMessage .= "{ldelim}$this->_{$textUtil->CamelText($oField->getField())}{rdelim} is not a valid value for {$textUtil->CamelText($oField->getField())}";
			$isValid = false;
		}
{if $oField->getSize() > 0}
		if ( $isValid && strlen($this->_{$textUtil->CamelText($oField->getField())}) > {$oField->getSize()} ) {
			$inMessage .= "{$textUtil->CamelText($oField->getField())} cannot be more than {$oField->getSize()} characters";
			$isValid = false;
		}
		if ( $isValid && strlen($this->_{$textUtil->CamelText($oField->getField())}) <= 1 ) {
			$inMessage .= "{$textUtil->CamelText($oField->getField())} must be more than 1 character";
			$isValid = false;
		}
{/if}
{if count($oField->getValues()) > 0}
		if ( $isValid && $this->_{$textUtil->CamelText($oField->getField())} != '' && !in_array($this->_{$textUtil->CamelText($oField->getField())}, array({foreach name=checkarr key=key item=value from=$oField->getValues()}self::{$oField->getField()|upper}_{$value|upper|regex_replace:'/\W/':'_'}{if !$smarty.foreach.checkarr.last}, {/if}{/foreach})) ) {
			$inMessage .= "{$textUtil->CamelText($oField->getField())} must be one of {foreach name=checkarr2 key=key item=value from=$oField->getValues()}{$oField->getField()|upper}_{$value|upper|regex_replace:'/\W/':'_'}{if !$smarty.foreach.checkarr2.last}, {/if}{/foreach}";
			$isValid = false;
		}
{/if}
{elseif $oField->getPhpType() == 'boolean'}
		if ( !is_bool($this->_{$textUtil->CamelText($oField->getField())}) && {if $oField->getIsNull()}$this->_{$textUtil->CamelText($oField->getField())} !== null && {/if}$this->_{$textUtil->CamelText($oField->getField())} !== false ) {
			$inMessage .= "{$textUtil->CamelText($oField->getField())} is not a valid value for {$textUtil->CamelText($oField->getField())}";
			$isValid = false;
		}
{elseif $oField->getPhpType() == 'datetime'}
		if ( !is_string($this->_{$textUtil->CamelText($oField->getField())}) && {if $oField->getIsNull()}$this->_{$textUtil->CamelText($oField->getField())} !== null && {/if}$this->_{$textUtil->CamelText($oField->getField())} !== '' ) {
			$inMessage .= "{ldelim}$this->_{$textUtil->CamelText($oField->getField())}{rdelim} is not a valid value for {$textUtil->CamelText($oField->getField())}";
			$isValid = false;
		}
{elseif $oField->getPhpType() == 'timestamp'}
		if ( !is_numeric($this->_{$textUtil->CamelText($oField->getField())}) && {if $oField->getIsNull()}$this->_{$textUtil->CamelText($oField->getField())} !== null && {/if}$this->_{$textUtil->CamelText($oField->getField())} !== 0 ) {
			$inMessage .= "{ldelim}$this->_{$textUtil->CamelText($oField->getField())}{rdelim} is not a valid value for {$textUtil->CamelText($oField->getField())}";
			$isValid = false;
		}
{/if}
		return $isValid;
	}
{/foreach}



	/**
	 * Returns true if object has been modified
	 *
	 * @return boolean
	 */
	function isModified() {
		return $this->_Modified;
	}

	/**
	 * Set the status of the object if it has been changed
	 *
	 * @param boolean $status
	 * @return {$className}
	 */
	function setModified($status = true) {
		$this->_Modified = $status;
		return $this;
	}

	/**
	 * Returns the primaryKey index
	 *
	 * @return string
	 */
	function getPrimaryKey() {
		return {foreach name=pKey key=seqID item=index from=$primaryKey}$this->_{$textUtil->CamelText($index->getColumnName())}{if !$smarty.foreach.pKey.last}.'.'.{/if}{/foreach};
	}
{foreach name=properties item=oField from=$oTableDefinition->getFields()}

	/**
	 * Return value of $_{$textUtil->CamelText($oField->getField())}
	 *
	 * @return {$oField->getPhpType()}
	 * @access public
	 */
	function get{$textUtil->CamelText($oField->getField())}() {
		return $this->_{$textUtil->CamelText($oField->getField())};
	}

	/**
	 * Set $_{$textUtil->CamelText($oField->getField())} to {$textUtil->CamelText($oField->getField())}
	 *
	 * @param {$oField->getPhpType()} $in{$textUtil->CamelText($oField->getField())}
	 * @return {$className}
	 * @access public
	 */
	function set{$textUtil->CamelText($oField->getField())}($in{$textUtil->CamelText($oField->getField())}) {
		if ( $in{$textUtil->CamelText($oField->getField())} !== $this->_{$textUtil->CamelText($oField->getField())} ) {
			$this->_{$textUtil->CamelText($oField->getField())} = $in{$textUtil->CamelText($oField->getField())};
			$this->setModified();
		}
		return $this;
	}
{/foreach}

	/**
	 * Returns $_MarkForDeletion
	 *
	 * @return boolean
	 */
	function getMarkForDeletion() {
		return $this->_MarkForDeletion;
	}

	/**
	 * Set $_MarkForDeletion to $inMarkForDeletion
	 *
	 * @param boolean $inMarkForDeletion
	 * @return {$className}
	 */
	function setMarkForDeletion($inMarkForDeletion) {
		if ( $inMarkForDeletion !== $this->_MarkForDeletion ) {
			$this->_MarkForDeletion = $inMarkForDeletion;
		}
		return $this;
	}
}
Return current item: Scorpio Framework for PHP