root/tags/RELEASE_0_9_0B1/examples/example_creator_db_mysql.php

Revision 117, 1.8 kB (checked in by argh, 4 years ago)

Massive update of the examples collection; added the patExampleGen examples framework; commented all examples; reworked all the templates...

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php
2 /**
3  * patForms_Creator_DB examples
4  *
5  * patForms_Creator is a subpackage of patForms that provides
6  * several formbuilder classes that create a form from
7  * a datasource.
8  *
9  * WARNING:
10  * The Creator subpackage is still in devel state!
11  *
12  * @access        public
13  * @package        patForms
14  * @subpackage    Examples
15  * @author        Stephan Schmidt <schst@php-tools.net
16  * @author        Sebastian Mordziol <argh@php-tools.net>
17  * @license        LGPL, see license.txt for details
18  * @link        http://www.php-tools.net
19  */
20
21     /**
22      * Main examples prepend file, needed *only* for the examples framework!
23      */
24     include_once 'patExampleGen/prepend.php';
25     $exampleGen->displayHead( 'Example' );
26
27     
28     // EXAMPLE START ------------------------------------------------------
29
30     /**
31      * main patForms class
32      */
33     require_once $neededFiles['patForms'];
34     
35     /**
36      * patErrorManager class
37      */
38     require_once $neededFiles['patErrorManager'];
39
40
41     // create the creator :)
42     $creator = &patForms::createCreator( 'DB_Mysql' );
43     
44     // create the form object from the given database
45     $form =& $creator->create( 'mysql://root:@localhost/pat', 'patForms_Storage' );
46     
47     // create the needed renderer
48     $renderer    =&    patForms::createRenderer( "Array" );
49     
50     // set the renderer
51     $form->setRenderer( $renderer );
52     
53     // use auto-validation
54     $form->setAutoValidate( 'save' );
55
56     // serialize the elements
57     $elements = $form->renderForm();
58     
59     
60     // ERROR DISPLAY ------------------------------------------------------
61     if( $form->isSubmitted() )
62     {
63         displayErrors( $form );    // see patExampleGen/customFunctions.php
64     }
65
66     // DISPLAY FORM ------------------------------------------------------
67     displayForm( $form, $elements ); // see patExampleGen/customFunctions.php
68
69
70     
71     
72     // EXAMPLE END ------------------------------------------------------
73     $exampleGen->displayFooter();
74 ?>
Note: See TracBrowser for help on using the browser.