From 104100cccd4e7b30ec84ed055fb78745dd94b5b0 Mon Sep 17 00:00:00 2001 From: mikl <> Date: Thu, 16 Oct 2008 08:46:57 +0000 Subject: Ticket #891 (new static method table() in TActiveRecord) --- framework/Data/ActiveRecord/TActiveRecordGateway.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'framework/Data/ActiveRecord/TActiveRecordGateway.php') diff --git a/framework/Data/ActiveRecord/TActiveRecordGateway.php b/framework/Data/ActiveRecord/TActiveRecordGateway.php index 23104c00..112ec3e8 100644 --- a/framework/Data/ActiveRecord/TActiveRecordGateway.php +++ b/framework/Data/ActiveRecord/TActiveRecordGateway.php @@ -31,6 +31,10 @@ class TActiveRecordGateway extends TComponent * Constant name for specifying optional table name in TActiveRecord. */ const TABLE_CONST='TABLE'; + /** + * Method name for returning optional table name in in TActiveRecord + */ + const TABLE_METHOD='table'; /** * Record gateway constructor. @@ -65,6 +69,14 @@ class TActiveRecordGateway extends TComponent throw new TActiveRecordException('ar_invalid_tablename_property', get_class($record),self::TABLE_CONST); return $value; + } + elseif ($class->hasMethod(self::TABLE_METHOD)) + { + $value = call_user_func(array(get_class($record),self::TABLE_METHOD)); + if(empty($value)) + throw new TActiveRecordException('ar_invalid_tablename_method', + get_class($record),self::TABLE_METHOD); + return $value; } else return strtolower(get_class($record)); -- cgit v1.2.3