Login | Register
My pages Projects Community openCollabNet

Discussions > dev > [propel-dev] support for "readOnly" tables

Discussion topic

Back to topic list

[propel-dev] support for "readOnly" tables


Author hlellelid
Full name Hans Lellelid
Date 2004-07-14 16:40:38 PDT
Message I added a new attribute, "readOnly", to the <table> element. As it
suggests, this instructs Propel to build read-only versions of that
table. Notable differences in read-only tables are:
  * no column value mutator set*() methods (only the relationships
setters exist, to support the doSelectJoin*() methods)
  * no peer doUpdate(), doDelete*(), doInsert(), doValidate()
  * no object save(), delete(), validate()
  * object classes do not (cannot) implement Persistent interface

The need for read-only tables is driven largely by a desire to loosely
support SQL VIEWs. For those that don't know, views are table-like
structures that are created using a query. For example (postgres):
  CREATE VIEW expired_content AS SELECT c.id, c.name FROM content c
WHERE expired = 't';

That view could be setup to be updateable, but in many cases the queries
are quite complex & there's no way to map changes back to the database.
In these (probably most) cases VIEWS are simply read-only virtual
tables. With the readOnly and the skipSql attributes, Propel can
loosely support views:

<table name="expired_content" skipSql="true" readOnly="true">
  <column type="INTEGER" primaryKey="true"/>
  <column type="VARCHAR" size="32"/>

Of course, you still have to create the view manually, but this way the
object model is generated to work with that view. Propel will probably
never natively support views since that feature is supported by only a
few of the databases that Propel supports; however, I definitely think
it should be as easy as possible to make use of db features like this.

The smaller read-only classes could also be generated for use on public
(read-only) sites, while full read-write versions could be built for the
admin/backend interfaces. In short, it seems like a quite useful
feature. This feature should be considered experimental; however, it
doesn't have any effect on existing code.


To unsubscribe, e-mail: dev-unsubscribe@prop​el.tigris.org
For additional commands, e-mail: dev-help at propel dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »


Show all messages in topic

[propel-dev] support for "readOnly" tables hlellelid Hans Lellelid 2004-07-14 16:40:38 PDT
Messages per page: