Form Storage -- Flat Table: Difference between revisions

From IHRIS Wiki
No edit summary
Line 25: Line 25:
===Global Options===
===Global Options===
There are global options for specifying a the mapping between components and databases
There are global options for specifying a the mapping between components and databases
  /modules/forms/storage_options/multi_flat
  /modules/forms/storage_options/flat
This has the structure:
This has the structure:
*table_prefix: Optional scalar node.  The value pre-pended to a form name to give the table name where the data is stored.  If not set it is 'hippo_', the prefix used for the caching of  form data to flat tables.
*table_prefix: Optional scalar node.  The value pre-pended to a form name to give the table name where the data is stored.  If not set it is 'hippo_', the prefix used for the caching of  form data to flat tables.

Revision as of 12:55, 28 July 2009

The Flat Table storage mechanism allows you to map any flat table that you have in your database into a form.

Storage Options in Magic Data

To specify that the form $form has a flat table storage mechanism set by setting

modules/forms/forms/$form/storage

to have value flat.

The options specifying a flat table storage for $form are stored at:

/modules/forms/forms/$form/storage_options/flat

It has the following structure:

  • table: Optional scalar node. The table to use. E.g. my_table, `my weird_table`, `some_other_database`.`table`. You are responsible for back-tics if required. If it is not set, it determines the table name from the table_prefix set in the global options.
  • id: Optional parent node. The data defining how to associate an id per row of this table. If it is not set, the the data is populate from the column 'id.'
    • col: Optional scalar node. Specifies a column of the table to be used as the id. You are responsible for back-tics.
    • function: Optional scalar node. Specifies a SQL function whose result will the id for the form. 'col' takes precedence.
  • fields: Optional parent node. Specifies how the data of the your form is associate to a row of your table. Each child of this node is the name of a field $field of your form. By default, all fields of a form are populated, and are all assumed to come from the column with that field name.
    • $field: Parent node with the following child nodes.
      • col: Optional scalar node. Specifies a column of the table to be used as the id. You are responsible for back-tics.
      • function: Optional scalar node. Optional scalar node. Specifies a SQL function whose result will as the value for the field. 'col' takes precedence.
      • enabled: Optional scalar node. If present and evaluates to false, it means we should not populate this field.
  • parent: Optional parent node. If not present, we assume the parent is populated from the column 'parent'. It has the following child nodes:
    • enabled: Optional scalar node. If present and evaluates to false, it means getParent() should return the trivial parent id, '0'.
    • col: Optional scalar node. Specifies a "column" of the table to be used as the id for the parent. You are responsible for back-tics.
    • function: Optional scalar node. Optional scalar node. Optional scalar node. Specifies a SQL function whose result will as the value for the parent form's id. 'col' takes precedence.
  • writable: Optional scalar node. Defines the write access to the table. If not present or its value cast to false, then the table is not consider to be writable. If its value casts to true, then it is considered writable and the save() method will actually do something.

Global Options

There are global options for specifying a the mapping between components and databases

/modules/forms/storage_options/flat

This has the structure:

  • table_prefix: Optional scalar node. The value pre-pended to a form name to give the table name where the data is stored. If not set it is 'hippo_', the prefix used for the caching of form data to flat tables.