summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/pages/Database
diff options
context:
space:
mode:
Diffstat (limited to 'demos/quickstart/protected/pages/Database')
-rw-r--r--demos/quickstart/protected/pages/Database/ActiveRecord.page16
1 files changed, 8 insertions, 8 deletions
diff --git a/demos/quickstart/protected/pages/Database/ActiveRecord.page b/demos/quickstart/protected/pages/Database/ActiveRecord.page
index a6e087b9..5fb7f41d 100644
--- a/demos/quickstart/protected/pages/Database/ActiveRecord.page
+++ b/demos/quickstart/protected/pages/Database/ActiveRecord.page
@@ -50,16 +50,16 @@
<li>Fetch relationships (related foreign objects) such as "has many", "has one", "belongs to" and "has many" via association table.</li>
<li>Lazy loading of relationships.</li>
</ul>
-<h2>Design Implications</h2>
-<p>
+<h2 id="144003">Design Implications</h2>
+<p id="720007" class="block-content">
Prado's implementation of Active Record does not maintain referential identity. Each object obtained using
Active Record is a copy of the data in the database. For example, If you ask for
a particular customer and get back a <tt>Customer</tt> object, the next time you ask for
that customer you get back another instance of a <tt>Customer</tt> object. This implies that a strict
comparison (i.e., using <tt>===</tt>) will return false, while loose comparison (i.e., using <tt>==</tt>) will
return true if the object values are equal by loose comparison.
-<p>
-<p>
+<p id="720008" class="block-content">
+<p id="720009" class="block-content">
This is design implication related to the following question.
<i>"Do you think of the customer as an object, of which there's only one,
or do you think of the objects you operate on as <b>copies</b> of the database?"</i>
@@ -1059,14 +1059,14 @@ arrays. E.g. <tt>$player->skills[] = new SkillRecord()</tt>. If <tt>array</tt> w
will be thrown.
</p>
-<h2>Column Mapping</h2>
-<p>
+<h2 id="144004">Column Mapping</h2>
+<p id="720010" class="block-content">
Since v3.1.1, Active Record starts to support column mapping. Column mapping allows developers
to address columns in Active Record using a more consistent naming convention. In particular,
using column mapping, one can access a column using whatever name he likes, rather than limited by
the name defined in the database schema.
</p>
-<p>
+<p id="720011" class="block-content">
To use column mapping, declare a static array named <tt>COLUMN_MAPPING</tt> in the Active Record class.
The keys of the array are column names (called <i>physical column names</i>) as defined in the database
schema, while the values are corresponding property names (called <i>logical column names</i>) defined
@@ -1093,7 +1093,7 @@ class UserRecord extends TActiveRecord
//....
}
</com:TTextHighlighter>
-<p>
+<p id="720012" class="block-content">
With the above column mapping, we can address <tt>first_name</tt> using <tt>$userRecord->firstName</tt>
instead of <tt>$userRecord->first_name</tt>. This helps separation of logic and model.
</p>