summaryrefslogtreecommitdiff
path: root/framework/Data/ActiveRecord
diff options
context:
space:
mode:
authorwei <>2007-02-27 23:48:49 +0000
committerwei <>2007-02-27 23:48:49 +0000
commit7a9626af3bef5c712901597065745d9572c3f097 (patch)
treeb63b6c5ef530004ac40d57c2b58ddca773bea05d /framework/Data/ActiveRecord
parent4c86659bc90d9134b0f901572c5417aa7d9cec18 (diff)
BC: Deprecate TActiveRecord::getRecordFinder() in favour of TActiveRecord::finder().
Diffstat (limited to 'framework/Data/ActiveRecord')
-rw-r--r--framework/Data/ActiveRecord/Exceptions/messages.txt3
-rw-r--r--framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php2
-rw-r--r--framework/Data/ActiveRecord/TActiveRecord.php15
-rw-r--r--framework/Data/ActiveRecord/TActiveRecordConfig.php4
4 files changed, 17 insertions, 7 deletions
diff --git a/framework/Data/ActiveRecord/Exceptions/messages.txt b/framework/Data/ActiveRecord/Exceptions/messages.txt
index 1d7d6e7d..84b58fe5 100644
--- a/framework/Data/ActiveRecord/Exceptions/messages.txt
+++ b/framework/Data/ActiveRecord/Exceptions/messages.txt
@@ -15,4 +15,5 @@ ar_missing_pk_values = Missing primary key values in forming IN(key1, key2,
ar_pk_value_count_mismatch = Composite key value count mismatch in forming IN( (key1, key2, ..), (key3, key4, ..)) for table '{0}'.
ar_must_copy_from_array_or_object = $data in {0}::copyFrom($data) must be an object or an array.
ar_mismatch_column_names = In dynamic __call() method '{0}', no matching columns were found, valid columns for table '{2}' are '{1}'.
-ar_invalid_table = Missing, invalid or no permission for table/view '{0}'. \ No newline at end of file
+ar_invalid_table = Missing, invalid or no permission for table/view '{0}'.
+ar_invalid_finder_class_name = Class name for finder($className) method must not be 'TActiveRecord', you should override the finder() method in your record class or pass in a valid record class name. \ No newline at end of file
diff --git a/framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php b/framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php
index b55ceedc..4e96a19d 100644
--- a/framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php
+++ b/framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php
@@ -165,7 +165,7 @@ abstract class TScaffoldBase extends TTemplateControl
*/
protected function getRecordFinder()
{
- return TActiveRecord::getRecordFinder($this->getRecordClass());
+ return TActiveRecord::finder($this->getRecordClass());
}
/**
diff --git a/framework/Data/ActiveRecord/TActiveRecord.php b/framework/Data/ActiveRecord/TActiveRecord.php
index 7ab45a2b..8c789ec2 100644
--- a/framework/Data/ActiveRecord/TActiveRecord.php
+++ b/framework/Data/ActiveRecord/TActiveRecord.php
@@ -41,9 +41,9 @@ Prado::using('System.Data.ActiveRecord.TActiveRecordCriteria');
* public static final $_tablename='users'; //optional table name.
*
* //returns active record finder instance
- * public static function finder()
+ * public static function finder($className=__CLASS__)
* {
- * return self::getRecordFinder('UserRecord');
+ * return parent::finder($className);
* }
* }
*
@@ -143,9 +143,13 @@ abstract class TActiveRecord extends TComponent
* Returns the instance of a active record finder for a particular class.
* @param string active record class name.
* @return TActiveRecord active record finder instance.
+ * @throws TActiveRecordException if class name equals 'TActiveRecord'.
*/
- public static function getRecordFinder($class)
+ public static function finder($className=__CLASS__)
{
+ if($class==='TActiveRecord')
+ throw new TActiveRecordException('ar_invalid_finder_class_name');
+
static $finders = array();
if(!isset($finders[$class]))
{
@@ -156,6 +160,11 @@ abstract class TActiveRecord extends TComponent
return $finders[$class];
}
+ public static function getRecordFinder($className)
+ {
+ throw new TActiveRecordException('Deprecated method, use TActiveRecord::finder()');
+ }
+
/**
* Gets the record manager for this object, the default is to call
* TActiveRecordManager::getInstance().
diff --git a/framework/Data/ActiveRecord/TActiveRecordConfig.php b/framework/Data/ActiveRecord/TActiveRecordConfig.php
index 5670e64c..3f16287d 100644
--- a/framework/Data/ActiveRecord/TActiveRecordConfig.php
+++ b/framework/Data/ActiveRecord/TActiveRecordConfig.php
@@ -45,9 +45,9 @@ Prado::using('System.Data.TDataSourceConfig');
* public $blog_name;
* public $blog_author;
*
- * public static function finder()
+ * public static function finder($className=__CLASS__)
* {
- * return self::getRecordFinder('Blogs');
+ * return parent::finder($className);
* }
* }
* </code>