From 8aa27c48cd1b620e3a7dee1e2de2cdc67f4e9874 Mon Sep 17 00:00:00 2001 From: "ctrlaltca@gmail.com" <> Date: Sun, 22 May 2011 14:43:11 +0000 Subject: branch 3.1: misc doc updates --- .../protected/pages/Database/ActiveRecord.page | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 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 bc0df529..78947faf 100644 --- a/demos/quickstart/protected/pages/Database/ActiveRecord.page +++ b/demos/quickstart/protected/pages/Database/ActiveRecord.page @@ -50,16 +50,16 @@
  • Fetch relationships (related foreign objects) such as "has many", "has one", "belongs to" and "many to many" via association table.
  • Lazy loading of relationships.
  • -

    Design Implications

    -

    +

    Design Implications

    +

    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 Customer object, the next time you ask for that customer you get back another instance of a Customer object. This implies that a strict comparison (i.e., using ===) will return false, while loose comparison (i.e., using ==) will return true if the object values are equal by loose comparison. -

    -

    +

    +

    This is design implication related to the following question. "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 copies of the database?" @@ -876,8 +876,8 @@ class Category extends TActiveRecord } -

    Query Criteria for Related Objects

    -

    +

    Query Criteria for Related Objects

    +

    In the above, we show that an Active Record object can reference to its related objects by declaring a static class member $RELATIONS which specifies a list of relations. Each relation is specified as an array consisting of three elements: relation type, related AR class name, @@ -1147,14 +1147,14 @@ arrays. E.g. $player->skills[] = new SkillRecord(). If array w will be thrown.

    -

    Column Mapping

    -

    +

    Column Mapping

    +

    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.

    -

    +

    To use column mapping, declare a static array named COLUMN_MAPPING in the Active Record class. The keys of the array are column names (called physical column names) as defined in the database schema, while the values are corresponding property names (called logical column names) defined @@ -1181,7 +1181,7 @@ class UserRecord extends TActiveRecord //.... } -

    +

    With the above column mapping, we can address first_name using $userRecord->firstName instead of $userRecord->first_name. This helps separation of logic and model.

    -- cgit v1.2.3