From: alex <bin...@li...> - 2001-08-23 19:03:31
|
alex Thu Aug 23 12:03:25 2001 EDT Added files: /r2/binarycloud/docs/specs/xml EntityDefinition.php.xml QueryDefinition.qry.xml Log: Entity and Query definition xmls. Index: r2/binarycloud/docs/specs/xml/EntityDefinition.php.xml +++ r2/binarycloud/docs/specs/xml/EntityDefinition.php.xml <entity> <!-- the name of the entity --> <entity:name>furbees</entity:name> <!-- the manager which should be imported by EntityManager. the role of an individual Entity Manager is to check the data before a post to the DB happens. It allows developers to write complex rules for an entity into a class. --> <entity:manager>FurbeesManager<entity:manager> <!-- db-related stuff for compatibility with metabase. this allows for auto-generation of metabase schema files from entity definitions --> <entity:database> <!-- the db name to use when creating tables or databases --> <name>binarycloud_db</name> <!-- create the database? --> <create>0</create> <!-- the table this entity references --> <table> <!-- table name --> <name>furbee</name> <!-- an index declaration for the primary key --> <index> <name>furbee_id</name> <unique>1</unique> <field> <name>furbee_id</name> </field> </index> </table> <!-- a database sequence for the primary key --> <sequence> <name>furbee_id</name> <start>1</start> <on> <table>furbee</table> <field>furbee_id</field> </on> </sequence> </entity:database> <!-- field definitions are the 'heart' of an entity these definitions carry all of the information necessary to create schemas, do validation, and label fields in html. --> <entity:fields> <field> <!-- the field name --> <name>furbee_id</name> <!-- the field label, or "full name" --> <label>Furbee ID</label> <!-- the description of the field --> <desc>Unique ID for ever Furbee</desc> <!-- the path in the entity --> <path>furbee_id</path> <!-- must this field be valid to do a post of this entity? --> <required>true</required> <!-- is this the default field in the db table? --> <default>0</default> <!-- can the field be null? --> <notnull>1</notnull> <!-- what is the simple, 'database' type of this field? --> <type>int</type> <!-- the maximum number of chars allowed in input fields and posts --> <maxlength>20</maxlength> <!-- Processors are classes which will condition the input somehow. In this example, the class EncodeEntitiesProcessor would be imported by EntityManager and passed the input for this field. It would return the input run through htmlspecialchars() or maybe a custom method for encoding xml/html character entities. --> <processors> <processor> <name>EncodeEntitiesProcessor</name> <params> <param_name>value</param_name> </params> </processor> </processors> <!-- Validators are classes which are imported by entityManager as requested and run again input. There will be a default set of validators like EmailAddressValidator, PhoneNumberValidator, etc. These validators will be passed the input of the post in the sequence they are declared. Each validator will be run against the input, and return true or false. If false, entitymanager will return an error. --> <validators> <validator> <name>FASTASequenceValidator</name> <params> <param_name>value</param_name> </params> </validator> </validators> <!-- This is the UI control that will be used by the FormBuilder class as a default. In this case, an <input type="text" size="20"> would result. --> <uicontrol> <name>TextBoxControl</name> <params> <size>20</size> </params> </uicontrol> </field> <field> <name>furbee_type_id</name> <label>Furbee type ID</label> <desc>The id of the type of furbee</desc> <path>furbee_type_id</path> <required>true</required> <type>int</type> <maxlength>20</maxlength> <!-- If this is declared, EntityManager knows that this field is a 'pointer' to another entity. --> <entity>furbee_type</entity> </field> </entity:fields> <!-- this should only be required to map old schemas to entities - under normal circumstances the fields should match names the entsource field is the path to the entity field, the dbtarget is the path to the database field. --> <entity:schema> <map> <entsource>furbee_type_id</entsource> <dbtarget>furbee.furbeetypeid</dbtarget> </map> </entity:schema> </entity> Index: r2/binarycloud/docs/specs/xml/QueryDefinition.qry.xml +++ r2/binarycloud/docs/specs/xml/QueryDefinition.qry.xml <?xml version="1.0" ?> <queries> <query> <!-- the name of the query --> <name>QRY_USER_SELECT_NEWS</name> <!-- The SQL portion of the query maybe with placeholders ("?") --> <sql>SELECT newsid, news FROM news WHERE newsid = ?</sql> <!-- Types of the values the ? is going to replaced with. In order of appearance in the sql portion of the query --> <argtypes> <type>integer</type> </argtypes> </query> <!-- Another query without arguments --> <query> <name>QRY_USER_SELECT_ALLNEWS</name> <sql>SELECT newsid, news FROM news ORDER BY date DESC</sql> </query> </queries> <!-- this will be translated to a importable file: <?php $queries = array( 'QRY_USER_SELECT_NEWS' => array( 'QUERY' => "SELECT newsid, news FROM news WHERE newsid = ?", 'ARGTYPES' => array('integer') 'QRY_USER_SELECT_ALLNEWS' => array( 'QUERY' => "SELECT newsid, news FROM news ORDER BY date DESC" ) ); global $QueryManager; $QueryManager->LoadQueries($queries); unset($queries); ?> --> |