summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwei <>2007-02-27 23:48:49 +0000
committerwei <>2007-02-27 23:48:49 +0000
commit7a9626af3bef5c712901597065745d9572c3f097 (patch)
treeb63b6c5ef530004ac40d57c2b58ddca773bea05d
parent4c86659bc90d9134b0f901572c5417aa7d9cec18 (diff)
BC: Deprecate TActiveRecord::getRecordFinder() in favour of TActiveRecord::finder().
-rw-r--r--UPGRADE4
-rw-r--r--demos/address-book/protected/pages/AddressRecord.php19
-rw-r--r--demos/chat/protected/App_Code/ChatBufferRecord.php4
-rw-r--r--demos/chat/protected/App_Code/ChatUserRecord.php4
-rw-r--r--demos/quickstart/protected/controls/Comments/CommentBlock.php4
-rw-r--r--demos/quickstart/protected/pages/Database/ActiveRecord.page6
-rw-r--r--demos/quickstart/protected/pages/Database/SqlMap.page4
-rw-r--r--demos/quickstart/protected/pages/GettingStarted/Introduction.page39
-rw-r--r--demos/quickstart/protected/pages/Tutorial/AjaxChat.page8
-rw-r--r--demos/quickstart/protected/pages/Tutorial/fr/AjaxChat.page8
-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
-rwxr-xr-xframework/prado-cli.php4
-rw-r--r--tests/simple_unit/ActiveRecord/BaseActiveRecordTestCase.php9
-rw-r--r--tests/simple_unit/ActiveRecord/records/Blogs.php7
-rw-r--r--tests/simple_unit/ActiveRecord/records/DepSections.php7
-rw-r--r--tests/simple_unit/ActiveRecord/records/DepartmentRecord.php7
-rw-r--r--tests/simple_unit/ActiveRecord/records/SimpleUser.php7
-rw-r--r--tests/simple_unit/ActiveRecord/records/SqliteUsers.php7
-rw-r--r--tests/simple_unit/ActiveRecord/records/UserRecord.php7
-rw-r--r--tests/simple_unit/SqlMap/ActiveRecordSqlMapTest.php4
23 files changed, 112 insertions, 71 deletions
diff --git a/UPGRADE b/UPGRADE
index 7025adcd..aff235b5 100644
--- a/UPGRADE
+++ b/UPGRADE
@@ -13,6 +13,10 @@ if you want to upgrade from version A to version C and there is
version B between A and C, you need to following the instructions
for both A and B.
+Upgrading from v3.1a
+---------------------
+- TActiveRecord::getRecordFinder() is deprecated in favour of TActiveRecord::finder().
+
Upgrading from v3.0.x
---------------------
diff --git a/demos/address-book/protected/pages/AddressRecord.php b/demos/address-book/protected/pages/AddressRecord.php
index e61ed233..b7c93026 100644
--- a/demos/address-book/protected/pages/AddressRecord.php
+++ b/demos/address-book/protected/pages/AddressRecord.php
@@ -10,31 +10,26 @@ class AddressRecord extends TActiveRecord
* @var integer $id
* @soapproperty
*/
- public $id;
-
-
-
+ public $id;
+
/**
* @var string $username
* @soapproperty
*/
- public $username;
-
-
-
+ public $username;
+
/**
* @var string $phone
* @soapproperty
*/
- public $phone;
+ public $phone;
-
/**
* @return AddressRecord
*/
- public static function finder()
+ public static function finder($className==__CLASS__)
{
- return self::getRecordFinder('AddressRecord');
+ return parent::finder($className);
}
}
?> \ No newline at end of file
diff --git a/demos/chat/protected/App_Code/ChatBufferRecord.php b/demos/chat/protected/App_Code/ChatBufferRecord.php
index cf3c651f..03f94704 100644
--- a/demos/chat/protected/App_Code/ChatBufferRecord.php
+++ b/demos/chat/protected/App_Code/ChatBufferRecord.php
@@ -22,9 +22,9 @@ class ChatBufferRecord extends TActiveRecord
$this->_created_on = $value;
}
- public static function finder()
+ public static function finder($className=__CLASS__)
{
- return parent::getRecordFinder('ChatBufferRecord');
+ return parent::finder($className);
}
public function saveMessage()
diff --git a/demos/chat/protected/App_Code/ChatUserRecord.php b/demos/chat/protected/App_Code/ChatUserRecord.php
index 9bfb11cd..e5ebc761 100644
--- a/demos/chat/protected/App_Code/ChatUserRecord.php
+++ b/demos/chat/protected/App_Code/ChatUserRecord.php
@@ -19,9 +19,9 @@ class ChatUserRecord extends TActiveRecord
$this->_last_activity = $value;
}
- public static function finder()
+ public static function finder($className=__CLASS__)
{
- return parent::getRecordFinder('ChatUserRecord');
+ return parent::finder($className);
}
public function getUserList()
diff --git a/demos/quickstart/protected/controls/Comments/CommentBlock.php b/demos/quickstart/protected/controls/Comments/CommentBlock.php
index f2f6e9a1..b0f23d47 100644
--- a/demos/quickstart/protected/controls/Comments/CommentBlock.php
+++ b/demos/quickstart/protected/controls/Comments/CommentBlock.php
@@ -19,9 +19,9 @@ class CommentRecord extends TActiveRecord
public static $_tablename='qs_comments';
- public static function finder()
+ public static function finder($className=__CLASS__)
{
- return self::getRecordFinder('CommentRecord');
+ return parent::finder($className);
}
}
diff --git a/demos/quickstart/protected/pages/Database/ActiveRecord.page b/demos/quickstart/protected/pages/Database/ActiveRecord.page
index 2562f674..041a1126 100644
--- a/demos/quickstart/protected/pages/Database/ActiveRecord.page
+++ b/demos/quickstart/protected/pages/Database/ActiveRecord.page
@@ -81,9 +81,9 @@ class UserRecord extends TActiveRecord
/**
* @return TActiveRecord active record finder instance
*/
- public static function finder()
+ public static function finder($className=__CLASS__)
{
- return self::getRecordFinder('UserRecord');
+ return parent::finder($className);
}
}
</com:TTextHighlighter>
@@ -129,7 +129,7 @@ will raise an exception.
<p id="690486" class="block-content">
The static method <tt>finder()</tt> returns an <tt>UserRecord</tt> instance
that can be used to load records from the database. The loading of records
- using the finer methods is discuss a little later. The <tt>TActiveRecord::getRecordFinder()</tt>
+ using the finer methods is discuss a little later. The <tt>TActiveRecord::finder()</tt>
static method takes the name of the current Active Record class as parameter.
</p>
diff --git a/demos/quickstart/protected/pages/Database/SqlMap.page b/demos/quickstart/protected/pages/Database/SqlMap.page
index ce9e979e..c8ced852 100644
--- a/demos/quickstart/protected/pages/Database/SqlMap.page
+++ b/demos/quickstart/protected/pages/Database/SqlMap.page
@@ -221,9 +221,9 @@ class UserRecord extends TActiveRecord
/**
* @return TActiveRecord active record finder instance
*/
- public static function finder()
+ public static function finder($className=__CLASS__)
{
- return self::getRecordFinder('UserRecord');
+ return parent::finder($className);
}
}
</com:TTextHighlighter>
diff --git a/demos/quickstart/protected/pages/GettingStarted/Introduction.page b/demos/quickstart/protected/pages/GettingStarted/Introduction.page
index 87a54f0b..0871921a 100644
--- a/demos/quickstart/protected/pages/GettingStarted/Introduction.page
+++ b/demos/quickstart/protected/pages/GettingStarted/Introduction.page
@@ -4,6 +4,45 @@
<p id="10001">
This Quickstart tutorial is provided to help you quickly start building your own Web applications based on PRADO version 3.x.
</p>
+<div class="start-page">
+ <div class="concepts start-block">
+ <h2>How Prado Works</h2>
+ <p>Concepts and fundamentals</p>
+ <ol>
+ <li><a href="#">Building web applications with Prado</a></li>
+ <li><a href="#">Web controls and events</a></li>
+ <li><a href="#">Validating user input</a></li>
+ <li><a href="#">Connecting to your database</a></li>
+ <li><a href="#">Displaying data from database</a></li>
+ </ol>
+ </div>
+ <div class="examples start-block">
+ <h2>Examples and Demos</h2>
+ <ul>
+ <li><a href="../helloworld/">Hello World</a></li>
+ <li><a href="../currency-convert/">Currency Converter</a></li>
+ <li><a href="../address-book/">Address Book</a></li>
+ <li><a href="../blog/">Blog</a></li>
+ <li><a href="../chat/">AJAX Chat</a></li>
+ <li><a href="../time-tracker/">Project Time Tracker</a></li>
+ </ul>
+ <p>More examples in <a href="?page=Controls.Standard">Standard Controls</a>,
+ <a href="?page=Controls.Validation">Validation Controls</a> and
+ <a href="?page=Controls.Data">Data Controls</a>.
+ </div>
+
+ <div class="tutorials start-block">
+ <h2>Tutorials and Help</h2>
+ <ul>
+ <li><a href="?page=GettingStarted.HelloWorld">Hello World in detail</a></li>
+ <li><a href="?page=Tutorial.CurrencyConverter">Currency Converter Tutorial</a></li>
+ <li><a href="?page=Tutorial.AddressBook">Address Book Tutorial</a></li>
+ <li><a href="?page=Tutorial.AjaxChat">AJAX Chat Tutorial</a></li>
+ </ul>
+ </div>
+</div>
+
+
<p id="10002">
You may refer to the following resources if you find this tutorial does not fulfill all your needs.
</p>
diff --git a/demos/quickstart/protected/pages/Tutorial/AjaxChat.page b/demos/quickstart/protected/pages/Tutorial/AjaxChat.page
index 730ebab6..7d978a12 100644
--- a/demos/quickstart/protected/pages/Tutorial/AjaxChat.page
+++ b/demos/quickstart/protected/pages/Tutorial/AjaxChat.page
@@ -173,9 +173,9 @@ class ChatUserRecord extends TActiveRecord
public static $_tablename='chat_users';
- public static function finder()
+ public static function finder($className=__CLASS__)
{
- return parent::getRecordFinder('ChatUserRecord');
+ return parent::finder($className);
}
}
</com:TTextHighlighter>
@@ -522,9 +522,9 @@ class ChatBufferRecord extends TActiveRecord
$this->_created_on = $value;
}
- public static function finder()
+ public static function finder($className=__CLASS__)
{
- return parent::getRecordFinder('ChatBufferRecord');
+ return parent::finder($className);
}
}
</com:TTextHighlighter>
diff --git a/demos/quickstart/protected/pages/Tutorial/fr/AjaxChat.page b/demos/quickstart/protected/pages/Tutorial/fr/AjaxChat.page
index fc1997c8..7bc36d5f 100644
--- a/demos/quickstart/protected/pages/Tutorial/fr/AjaxChat.page
+++ b/demos/quickstart/protected/pages/Tutorial/fr/AjaxChat.page
@@ -173,9 +173,9 @@ class ChatUserRecord extends TActiveRecord
public static $_tablename='chat_users';
- public static function finder()
+ public static function finder($className=__CLASS__)
{
- return parent::getRecordFinder('ChatUserRecord');
+ return parent::finder($className);
}
}
</com:TTextHighlighter>
@@ -522,9 +522,9 @@ class ChatBufferRecord extends TActiveRecord
$this->_created_on = $value;
}
- public static function finder()
+ public static function finder($className=__CLASS__)
{
- return parent::getRecordFinder('ChatBufferRecord');
+ return parent::finder($className);
}
}
</com:TTextHighlighter>
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>
diff --git a/framework/prado-cli.php b/framework/prado-cli.php
index 5ccef4bc..8ede48ab 100755
--- a/framework/prado-cli.php
+++ b/framework/prado-cli.php
@@ -660,9 +660,9 @@ class $class extends TActiveRecord
$props
- public static function finder()
+ public static function finder($className=__CLASS__)
{
- return self::getRecordFinder('$class');
+ return parent::finder($className);
}
}
?>
diff --git a/tests/simple_unit/ActiveRecord/BaseActiveRecordTestCase.php b/tests/simple_unit/ActiveRecord/BaseActiveRecordTestCase.php
index 9e48fe5f..fbb1c927 100644
--- a/tests/simple_unit/ActiveRecord/BaseActiveRecordTestCase.php
+++ b/tests/simple_unit/ActiveRecord/BaseActiveRecordTestCase.php
@@ -1,5 +1,4 @@
-<?php
-
+<?php
Prado::using('System.Data.ActiveRecord.TActiveRecord');
class BaseRecordTest extends TActiveRecord
@@ -11,14 +10,14 @@ class BaseActiveRecordTestCase extends UnitTestCase
{
function test_finder_returns_same_instance()
{
- $obj1 = TActiveRecord::getRecordFinder('BaseRecordTest');
- $obj2 = TActiveRecord::getRecordFinder('BaseRecordTest');
+ $obj1 = TActiveRecord::finder('BaseRecordTest');
+ $obj2 = TActiveRecord::finder('BaseRecordTest');
$this->assertIdentical($obj1,$obj2);
}
function test_finder_throw_exception_when_save()
{
- $obj = TActiveRecord::getRecordFinder('BaseRecordTest');
+ $obj = TActiveRecord::finder('BaseRecordTest');
try
{
$obj->save();
diff --git a/tests/simple_unit/ActiveRecord/records/Blogs.php b/tests/simple_unit/ActiveRecord/records/Blogs.php
index 69bdecd9..c32ca6b6 100644
--- a/tests/simple_unit/ActiveRecord/records/Blogs.php
+++ b/tests/simple_unit/ActiveRecord/records/Blogs.php
@@ -1,14 +1,13 @@
-<?php
-
+<?php
class Blogs extends TActiveRecord
{
public $blog_id;
public $blog_name;
public $blog_author;
- public static function finder()
+ public static function finder($className=__CLASS__)
{
- return self::getRecordFinder('Blogs');
+ return parent::finder($className);
}
}
diff --git a/tests/simple_unit/ActiveRecord/records/DepSections.php b/tests/simple_unit/ActiveRecord/records/DepSections.php
index 476371bd..c172245c 100644
--- a/tests/simple_unit/ActiveRecord/records/DepSections.php
+++ b/tests/simple_unit/ActiveRecord/records/DepSections.php
@@ -1,5 +1,4 @@
-<?php
-
+<?php
class DepSections extends TActiveRecord
{
public $department_id;
@@ -8,9 +7,9 @@ class DepSections extends TActiveRecord
public static $_tablename='department_sections';
- public static function finder()
+ public static function finder($className=__CLASS__)
{
- return self::getRecordFinder('DepSections');
+ return parent::finder($className);
}
}
diff --git a/tests/simple_unit/ActiveRecord/records/DepartmentRecord.php b/tests/simple_unit/ActiveRecord/records/DepartmentRecord.php
index 64ab39d0..be0f5fd1 100644
--- a/tests/simple_unit/ActiveRecord/records/DepartmentRecord.php
+++ b/tests/simple_unit/ActiveRecord/records/DepartmentRecord.php
@@ -1,5 +1,4 @@
-<?php
-
+<?php
class DepartmentRecord extends TActiveRecord
{
public $department_id;
@@ -10,9 +9,9 @@ class DepartmentRecord extends TActiveRecord
public static $_tablename = 'departments';
- public static function finder()
+ public static function finder($className=__CLASS__)
{
- return self::getRecordFinder('DepartmentRecord');
+ return parent::finder($className);
}
}
diff --git a/tests/simple_unit/ActiveRecord/records/SimpleUser.php b/tests/simple_unit/ActiveRecord/records/SimpleUser.php
index a256ffaf..3112e203 100644
--- a/tests/simple_unit/ActiveRecord/records/SimpleUser.php
+++ b/tests/simple_unit/ActiveRecord/records/SimpleUser.php
@@ -1,14 +1,13 @@
-<?php
-
+<?php
class SimpleUser extends TActiveRecord
{
public $username;
public static $_tablename='simple_users';
- public static function finder()
+ public static function finder($className=__CLASS__)
{
- return self::getRecordFinder('SimpleUser');
+ return parent::finder($className);
}
}
diff --git a/tests/simple_unit/ActiveRecord/records/SqliteUsers.php b/tests/simple_unit/ActiveRecord/records/SqliteUsers.php
index 6a6b9be9..19940bc0 100644
--- a/tests/simple_unit/ActiveRecord/records/SqliteUsers.php
+++ b/tests/simple_unit/ActiveRecord/records/SqliteUsers.php
@@ -1,5 +1,4 @@
-<?php
-
+<?php
class SqliteUsers extends TActiveRecord
{
public $username;
@@ -8,9 +7,9 @@ class SqliteUsers extends TActiveRecord
public static $_tablename='users';
- public static function finder()
+ public static function finder($className=__CLASS__)
{
- return self::getRecordFinder('SqliteUsers');
+ return parent::finder($className);
}
}
diff --git a/tests/simple_unit/ActiveRecord/records/UserRecord.php b/tests/simple_unit/ActiveRecord/records/UserRecord.php
index 02534d6f..6ef0c637 100644
--- a/tests/simple_unit/ActiveRecord/records/UserRecord.php
+++ b/tests/simple_unit/ActiveRecord/records/UserRecord.php
@@ -1,5 +1,4 @@
-<?php
-
+<?php
class UserRecord extends TActiveRecord
{
public $username;
@@ -30,9 +29,9 @@ class UserRecord extends TActiveRecord
$this->_level=TPropertyValue::ensureInteger($level);
}
- public static function finder()
+ public static function finder($className=__CLASS__)
{
- return self::getRecordFinder('UserRecord');
+ return parent::finder($className);
}
}
diff --git a/tests/simple_unit/SqlMap/ActiveRecordSqlMapTest.php b/tests/simple_unit/SqlMap/ActiveRecordSqlMapTest.php
index 9dc944f5..1f018a02 100644
--- a/tests/simple_unit/SqlMap/ActiveRecordSqlMapTest.php
+++ b/tests/simple_unit/SqlMap/ActiveRecordSqlMapTest.php
@@ -16,9 +16,9 @@ class ActiveAccount extends TActiveRecord
private static $_tablename='Accounts';
- public static function finder()
+ public static function finder($className=__CLASS__)
{
- return self::getRecordFinder('ActiveAccount');
+ return parent::finder($className);
}
}