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.
---
demos/address-book/protected/pages/AddressRecord.php | 2 +-
demos/chat/protected/App_Code/ChatBufferRecord.php | 4 ++--
demos/chat/protected/App_Code/ChatUserRecord.php | 4 ++--
.../protected/controls/Comments/CommentBlock.php | 4 ++--
.../protected/pages/Database/ActiveRecord.page | 16 ++++++++--------
.../protected/pages/Database/Samples/Scaffold/Home.php | 4 ++--
demos/quickstart/protected/pages/Database/Scaffold.page | 4 ++--
demos/quickstart/protected/pages/Database/SqlMap.page | 6 +++---
demos/quickstart/protected/pages/Tutorial/AjaxChat.page | 8 ++++----
.../quickstart/protected/pages/Tutorial/fr/AjaxChat.page | 8 ++++----
10 files changed, 30 insertions(+), 30 deletions(-)
(limited to 'demos')
diff --git a/demos/address-book/protected/pages/AddressRecord.php b/demos/address-book/protected/pages/AddressRecord.php
index 55c4ba06..aaf8db7c 100644
--- a/demos/address-book/protected/pages/AddressRecord.php
+++ b/demos/address-book/protected/pages/AddressRecord.php
@@ -4,7 +4,7 @@
*/
class AddressRecord extends TActiveRecord
{
- public static $_tablename='addresses';
+ const TABLE='addresses';
/**
* @var integer $id
diff --git a/demos/chat/protected/App_Code/ChatBufferRecord.php b/demos/chat/protected/App_Code/ChatBufferRecord.php
index 03f94704..f4d53db0 100644
--- a/demos/chat/protected/App_Code/ChatBufferRecord.php
+++ b/demos/chat/protected/App_Code/ChatBufferRecord.php
@@ -2,14 +2,14 @@
class ChatBufferRecord extends TActiveRecord
{
+ const TABLE='chat_buffer';
+
public $id;
public $for_user;
public $from_user;
public $message;
private $_created_on;
- public static $_tablename='chat_buffer';
-
public function getCreated_On()
{
if($this->_created_on === null)
diff --git a/demos/chat/protected/App_Code/ChatUserRecord.php b/demos/chat/protected/App_Code/ChatUserRecord.php
index e5ebc761..b68fbd4d 100644
--- a/demos/chat/protected/App_Code/ChatUserRecord.php
+++ b/demos/chat/protected/App_Code/ChatUserRecord.php
@@ -2,11 +2,11 @@
class ChatUserRecord extends TActiveRecord
{
+ const TABLE='chat_users';
+
public $username;
private $_last_activity;
- public static $_tablename='chat_users';
-
public function getLast_Activity()
{
if($this->_last_activity === null)
diff --git a/demos/quickstart/protected/controls/Comments/CommentBlock.php b/demos/quickstart/protected/controls/Comments/CommentBlock.php
index b0f23d47..9c008491 100644
--- a/demos/quickstart/protected/controls/Comments/CommentBlock.php
+++ b/demos/quickstart/protected/controls/Comments/CommentBlock.php
@@ -10,6 +10,8 @@ $manager->setDbConnection($db);
class CommentRecord extends TActiveRecord
{
+ const TABLE='qs_comments';
+
public $id;
public $username;
public $date_added;
@@ -17,8 +19,6 @@ class CommentRecord extends TActiveRecord
public $block_id;
public $content;
- public static $_tablename='qs_comments';
-
public static function finder($className=__CLASS__)
{
return parent::finder($className);
diff --git a/demos/quickstart/protected/pages/Database/ActiveRecord.page b/demos/quickstart/protected/pages/Database/ActiveRecord.page
index 041a1126..0a8d6580 100644
--- a/demos/quickstart/protected/pages/Database/ActiveRecord.page
+++ b/demos/quickstart/protected/pages/Database/ActiveRecord.page
@@ -73,11 +73,11 @@ CREATE TABLE users
class UserRecord extends TActiveRecord
{
+ const TABLE='users'; //table name
+
public $username; //the column named "username" in the "users" table
public $email;
- public static $_tablename='users'; //table name
-
/**
* @return TActiveRecord active record finder instance
*/
@@ -89,15 +89,15 @@ class UserRecord extends TActiveRecord
Each property of the UserRecord class must correspond to a
- column with the same name in the "users" table. The static class variable
- $_tablename (must be public) is optional when the class name is the same as
- the table name in the database, otherwise $_tablename must
+ column with the same name in the "users" table. The class constant
+ TABLE is optional when the class name is the same as
+ the table name in the database, otherwise TABLE must
specify the table name that corresponds to your Active Record class.
Note:
-You may need to quote (specific to your database) the value of the $_tablename.
-E.g. MySQL uses back-ticks, $_tablename = "`database1`.`table1`"
+You may need to quote (specific to your database) the value of the TABLE.
+E.g. MySQL uses back-ticks, TABLE = "`database1`.`table1`"
@@ -120,7 +120,7 @@ class UserRecord extends TActiveRecord {
Info:
-
TActiveRecord can also work with database views by specifying the value
$_tablename
+
TActiveRecord can also work with database views by specifying the constant
TABLE
corresponding to the view name. However, objects returned
from views are read-only, calling the
save() or
delete() method
will raise an exception.
diff --git a/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.php b/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.php
index 9bfe3f6d..45d72f1f 100644
--- a/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.php
+++ b/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.php
@@ -5,12 +5,12 @@ Prado::using('System.Data.ActiveRecord.Scaffold.TScaffoldView');
class AddressRecord extends TActiveRecord
{
+ const TABLE='addresses';
+
public $id;
public $username;
public $phone;
- public static $_tablename='addresses';
-
//for demo, we use static db here
//otherwise we should use TActiveRecordConfig in application.xml
private static $_db;
diff --git a/demos/quickstart/protected/pages/Database/Scaffold.page b/demos/quickstart/protected/pages/Database/Scaffold.page
index 36a0ec21..055cac26 100644
--- a/demos/quickstart/protected/pages/Database/Scaffold.page
+++ b/demos/quickstart/protected/pages/Database/Scaffold.page
@@ -39,10 +39,10 @@ table as defined in the
Active Record
class UserRecord extends TActiveRecord
{
+ const TABLE='users';
+
public $username;
public $email;
-
- public static $_tablename='users';
}
diff --git a/demos/quickstart/protected/pages/Database/SqlMap.page b/demos/quickstart/protected/pages/Database/SqlMap.page
index c8ced852..a4082527 100644
--- a/demos/quickstart/protected/pages/Database/SqlMap.page
+++ b/demos/quickstart/protected/pages/Database/SqlMap.page
@@ -213,11 +213,11 @@ $user = $sqlmap->queryForObject("SelectUsers");
class UserRecord extends TActiveRecord
{
+ const TABLE='users'; //table name
+
public $username; //the column named "username" in the "users" table
public $email;
-
- private static $_tablename='users'; //table name
-
+
/**
* @return TActiveRecord active record finder instance
*/
diff --git a/demos/quickstart/protected/pages/Tutorial/AjaxChat.page b/demos/quickstart/protected/pages/Tutorial/AjaxChat.page
index 7d978a12..4e40b33a 100644
--- a/demos/quickstart/protected/pages/Tutorial/AjaxChat.page
+++ b/demos/quickstart/protected/pages/Tutorial/AjaxChat.page
@@ -168,11 +168,11 @@ as App_Code/chat.db.
class ChatUserRecord extends TActiveRecord
{
+ const TABLE='chat_users';
+
public $username;
public $last_activity;
- public static $_tablename='chat_users';
-
public static function finder($className=__CLASS__)
{
return parent::finder($className);
@@ -502,14 +502,14 @@ The corresponding ChatBufferRecord class is saved as
class ChatBufferRecord extends TActiveRecord
{
+ const TABLE='chat_buffer';
+
public $id;
public $for_user;
public $from_user;
public $message;
private $_created_on;
- public static $_tablename='chat_buffer';
-
public function getCreated_On()
{
if($this->_created_on === null)
diff --git a/demos/quickstart/protected/pages/Tutorial/fr/AjaxChat.page b/demos/quickstart/protected/pages/Tutorial/fr/AjaxChat.page
index 7bc36d5f..24c5ea76 100644
--- a/demos/quickstart/protected/pages/Tutorial/fr/AjaxChat.page
+++ b/demos/quickstart/protected/pages/Tutorial/fr/AjaxChat.page
@@ -168,11 +168,11 @@ as App_Code/chat.db.
class ChatUserRecord extends TActiveRecord
{
+ const TABLE='chat_users';
+
public $username;
public $last_activity;
- public static $_tablename='chat_users';
-
public static function finder($className=__CLASS__)
{
return parent::finder($className);
@@ -502,14 +502,14 @@ The corresponding ChatBufferRecord class is saved as
class ChatBufferRecord extends TActiveRecord
{
+ const TABLE='chat_buffer';
+
public $id;
public $for_user;
public $from_user;
public $message;
private $_created_on;
- public static $_tablename='chat_buffer';
-
public function getCreated_On()
{
if($this->_created_on === null)
--
cgit v1.2.3