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. --- .../protected/pages/Database/ActiveRecord.page | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'demos/quickstart/protected/pages/Database/ActiveRecord.page') 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. -- cgit v1.2.3