From 8a674fb83fa2dd80bc653745e03b24450a9cf68d Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 6 Mar 2007 20:40:51 +0000 Subject: changed the way to specify active record table. --- framework/Data/ActiveRecord/TActiveRecordGateway.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'framework/Data/ActiveRecord/TActiveRecordGateway.php') diff --git a/framework/Data/ActiveRecord/TActiveRecordGateway.php b/framework/Data/ActiveRecord/TActiveRecordGateway.php index c925f3c9..f9cc5bbd 100644 --- a/framework/Data/ActiveRecord/TActiveRecordGateway.php +++ b/framework/Data/ActiveRecord/TActiveRecordGateway.php @@ -25,9 +25,9 @@ class TActiveRecordGateway extends TComponent private $_tables=array(); //meta data cache. /** - * Property name for optional table name in TActiveRecord. + * Constant name for specifying optional table name in TActiveRecord. */ - const PROPERTY_TABLE_NAME='_tablename'; + const TABLE_CONST='TABLE'; /** * Record gateway constructor. @@ -47,7 +47,7 @@ class TActiveRecordGateway extends TComponent } /** - * Gets the table name from the $_tablename property of the active record + * Gets the table name from the 'TABLE' constant of the active record * class if defined, otherwise use the class name as table name. * @param TActiveRecord active record instance * @return string table name for the given record class. @@ -55,12 +55,12 @@ class TActiveRecordGateway extends TComponent public function getTableName(TActiveRecord $record) { $class = new ReflectionClass($record); - if($class->hasProperty(self::PROPERTY_TABLE_NAME)) + if($class->hasConstant(self::TABLE_CONST)) { - $value = $class->getProperty(self::PROPERTY_TABLE_NAME)->getValue(); - if($value===null) + $value = $class->getConstant(self::TABLE_CONST); + if(empty($value)) throw new TActiveRecordException('ar_invalid_tablename_property', - get_class($record),self::PROPERTY_TABLE_NAME); + get_class($record),self::TABLE_CONST); return $value; } else -- cgit v1.2.3