summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/pages/Database
diff options
context:
space:
mode:
authorxue <>2007-03-06 20:40:51 +0000
committerxue <>2007-03-06 20:40:51 +0000
commit8a674fb83fa2dd80bc653745e03b24450a9cf68d (patch)
tree83f72026185075b0ffacf5c1996d3424b0e2f31f /demos/quickstart/protected/pages/Database
parent2ab695a553abf26e530f5e97c1ea357233d80998 (diff)
changed the way to specify active record table.
Diffstat (limited to 'demos/quickstart/protected/pages/Database')
-rw-r--r--demos/quickstart/protected/pages/Database/ActiveRecord.page16
-rw-r--r--demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.php4
-rw-r--r--demos/quickstart/protected/pages/Database/Scaffold.page4
-rw-r--r--demos/quickstart/protected/pages/Database/SqlMap.page6
4 files changed, 15 insertions, 15 deletions
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
<com:TTextHighlighter Language="php" CssClass="source block-content" id="code_690148">
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
</com:TTextHighlighter>
</p>
<p id="690485" class="block-content">Each property of the <tt>UserRecord</tt> class must correspond to a
- column with the same name in the "users" table. The static class variable
- <tt>$_tablename</tt> (must be public) is optional when the class name is the same as
- the table name in the database, otherwise <tt>$_tablename</tt> must
+ column with the same name in the "users" table. The class constant
+ <tt>TABLE</tt> is optional when the class name is the same as
+ the table name in the database, otherwise <tt>TABLE</tt> must
specify the table name that corresponds to your Active Record class.
</p>
<div class="note"><b class="note">Note:</b>
-You may need to quote (specific to your database) the value of the <tt>$_tablename</tt>.
-E.g. MySQL uses back-ticks, <tt>$_tablename = "`database1`.`table1`"</tt>
+You may need to quote (specific to your database) the value of the <tt>TABLE</tt>.
+E.g. MySQL uses back-ticks, <tt>TABLE = "`database1`.`table1`"</tt>
</div>
<p class="block-content" id="ar_as_component">
@@ -120,7 +120,7 @@ class UserRecord extends TActiveRecord {
</com:TTextHighlighter>
<div class="info"><b class="note">Info:</b>
-<tt>TActiveRecord</tt> can also work with database views by specifying the value <tt>$_tablename</tt>
+<tt>TActiveRecord</tt> can also work with database views by specifying the constant <tt>TABLE</tt>
corresponding to the view name. However, objects returned
from views are read-only, calling the <tt>save()</tt> or <tt>delete()</tt> 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 <a href="?page=Database.ActiveRecord">Active Record</a>
<com:TTextHighlighter Language="php" CssClass="source">
class UserRecord extends TActiveRecord
{
+ const TABLE='users';
+
public $username;
public $email;
-
- public static $_tablename='users';
}
</com:TTextHighlighter>
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");
<com:TTextHighlighter Language="php" CssClass="source block-content" id="code_700173">
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
*/