From 1ae09931b2572d9c3067c99f841a60cb3330b3f3 Mon Sep 17 00:00:00 2001 From: wei <> Date: Thu, 3 May 2007 00:48:04 +0000 Subject: Update active relations docs --- .gitattributes | 6 ++ .../protected/pages/Database/ActiveRecord.page | 29 ++++-- .../protected/pages/Database/ar_objects.png | Bin 0 -> 14323 bytes .../protected/pages/Database/ar_objects.vsd | Bin 0 -> 183296 bytes .../protected/pages/Database/ar_relations.png | Bin 0 -> 9278 bytes .../protected/pages/Database/ar_relations.vsd | Bin 0 -> 97280 bytes .../Relations/TActiveRecordBelongsTo.php | 20 ++-- .../Relations/TActiveRecordHasMany.php | 8 +- .../Relations/TActiveRecordHasManyAssociation.php | 107 ++++++++++++++++++++- .../ActiveRecord/Relations/TActiveRecordHasOne.php | 14 +-- .../Relations/TActiveRecordRelation.php | 11 +-- .../Relations/TActiveRecordRelationContext.php | 13 ++- .../Scaffold/InputBuilder/TScaffoldInputCommon.php | 1 + .../ActiveRecord/Scaffold/TScaffoldListView.php | 18 ++-- .../Data/ActiveRecord/Scaffold/TScaffoldView.php | 4 +- framework/Data/ActiveRecord/TActiveRecord.php | 1 + .../Data/Common/Mssql/TMssqlCommandBuilder.php | 6 +- framework/Data/Common/Mssql/TMssqlTableInfo.php | 1 - .../Data/Common/Sqlite/TSqliteCommandBuilder.php | 48 +++++++++ framework/Data/Common/Sqlite/TSqliteMetaData.php | 2 +- framework/Data/Common/Sqlite/TSqliteTableInfo.php | 9 ++ framework/Data/Common/TDbCommandBuilder.php | 39 ++++---- framework/prado-cli.php | 5 +- .../tickets/protected/pages/Ticket614.page | 13 +++ 24 files changed, 277 insertions(+), 78 deletions(-) create mode 100644 demos/quickstart/protected/pages/Database/ar_objects.png create mode 100644 demos/quickstart/protected/pages/Database/ar_objects.vsd create mode 100644 demos/quickstart/protected/pages/Database/ar_relations.png create mode 100644 demos/quickstart/protected/pages/Database/ar_relations.vsd create mode 100644 framework/Data/Common/Sqlite/TSqliteCommandBuilder.php create mode 100644 tests/FunctionalTests/tickets/protected/pages/Ticket614.page diff --git a/.gitattributes b/.gitattributes index eee67148..ca665df6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1268,6 +1268,10 @@ demos/quickstart/protected/pages/Database/Samples/Scaffold/sqlite.db -text demos/quickstart/protected/pages/Database/Samples/config.xml -text demos/quickstart/protected/pages/Database/Scaffold.page -text demos/quickstart/protected/pages/Database/SqlMap.page -text +demos/quickstart/protected/pages/Database/ar_objects.png -text +demos/quickstart/protected/pages/Database/ar_objects.vsd -text +demos/quickstart/protected/pages/Database/ar_relations.png -text +demos/quickstart/protected/pages/Database/ar_relations.vsd -text demos/quickstart/protected/pages/Database/diagram.png -text demos/quickstart/protected/pages/Database/object_states.png -text demos/quickstart/protected/pages/Database/sqlmap_active_record.png -text @@ -1646,6 +1650,7 @@ framework/Data/Common/Mysql/TMysqlTableInfo.php -text framework/Data/Common/Pgsql/TPgsqlMetaData.php -text framework/Data/Common/Pgsql/TPgsqlTableColumn.php -text framework/Data/Common/Pgsql/TPgsqlTableInfo.php -text +framework/Data/Common/Sqlite/TSqliteCommandBuilder.php -text framework/Data/Common/Sqlite/TSqliteMetaData.php -text framework/Data/Common/Sqlite/TSqliteTableColumn.php -text framework/Data/Common/Sqlite/TSqliteTableInfo.php -text @@ -2540,6 +2545,7 @@ tests/FunctionalTests/tickets/protected/pages/Ticket587.page -text tests/FunctionalTests/tickets/protected/pages/Ticket587.php -text tests/FunctionalTests/tickets/protected/pages/Ticket605.page -text tests/FunctionalTests/tickets/protected/pages/Ticket606.page -text +tests/FunctionalTests/tickets/protected/pages/Ticket614.page -text tests/FunctionalTests/tickets/protected/pages/Ticket68.page -text tests/FunctionalTests/tickets/protected/pages/Ticket72.page -text tests/FunctionalTests/tickets/protected/pages/Ticket72.php -text diff --git a/demos/quickstart/protected/pages/Database/ActiveRecord.page b/demos/quickstart/protected/pages/Database/ActiveRecord.page index c3cf663b..967aae89 100644 --- a/demos/quickstart/protected/pages/Database/ActiveRecord.page +++ b/demos/quickstart/protected/pages/Database/ActiveRecord.page @@ -49,15 +49,20 @@
  • Finder methods to wrap commonly used SQL queries and return Active Record objects.
  • Update existing records and insert new records into the database.
  • +

    Database Supported

    The Active Record implementation utilizes the Prado DAO classes for data access. -The current Active Record implementation supports -MySQL, -Postgres SQL and -SQLite databases. -Support for other databases can be provided when there are sufficient demand. +The current Active Record implementation supports the following database.

    -

    Defining an Active Record

    + +

    Support for other databases can be provided when there are sufficient demand.

    + +

    Defining an Active Record

    Let us consider the following "users" table that contains two columns named "username" and "email", where "username" is also the primary key. @@ -412,6 +417,18 @@ catch(Exception $e) // an exception is raised if a query fails } +

    Active Record Relationships

    +

    +The Prado ActiveRecord implementation supports the foreign key mappings for database +that supports foreign key contraints. For ActiveRecord relationships to function the +underlying database must support foreign key constraints (e.g. MySQL with InnoDB). +

    + +

    Foreign Key Mapping

    + + +

    Association Table Mapping

    +

    References