From 4b78404c20490a615459267426ce9e6737bf4485 Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 14 Jul 2006 09:20:45 +0000 Subject: Moving files. --- .../protected/pages/Tutorial/TestSecond.page | 116 +++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 demos/sqlmap/protected/pages/Tutorial/TestSecond.page (limited to 'demos/sqlmap/protected/pages/Tutorial/TestSecond.page') diff --git a/demos/sqlmap/protected/pages/Tutorial/TestSecond.page b/demos/sqlmap/protected/pages/Tutorial/TestSecond.page new file mode 100644 index 00000000..706b5220 --- /dev/null +++ b/demos/sqlmap/protected/pages/Tutorial/TestSecond.page @@ -0,0 +1,116 @@ + + +

Playtest second!

+

Now that we have a passing test, we want to display some results as web pages. +The following examples utilize the Prado framework to display and manipulate +the database through SQLMap. Since SQLMap framework and Prado framework solve +different problems, they are both fairly independent, they can be used +together or separately.

+ +

SQLMap and Prado

+

To setup Prado, we need to create the follow files and directory structure +under our example/WebView directory.

+ +assets/ % application public assets + +protected/pages/Home.page % default page +protected/pages/Home.php % default page class +protected/runtime/ % run time data + +protected/application.xml % application configuration + +index.php % application entry point + + +

The application.xml and assets directory are not necessary but we +will make use of them later. The application.xml is used to define some +directory aliases and override the data source definitions in the +sqlmap.config. This is because SQLite database files are defined +relatively, otherwise we don't need to override the data source definitions. +The example application.xml is shown below, defining path aliases and override SQLite database +location.

+ + + + + + + + + + + + + + + + + + + +

The entry point to a Prado application in this example is index.php +and generally contains the following code.

+ + +<?php +error_reporting(E_ALL); +require_once('/path/to/prado/framework/prado.php'); +$application=new TApplication; +$application->run(); +?> + + +

Now we are ready to setup a page to display our list of people. +The following sample shows the Prado code for our display page. The key +piece is the TDataGrid. We save the file as Home.page.

+ + + + + + Person + + +<com:TForm> +

Person List

+ <com:TDataGrid id="personList"> + <com:TBoundColumn DataField="BirthDate" + HeaderText="Birth Date"/> + </com:TDataGrid> +</com:TForm> + + +
+ +

Of course, we still need to populate that TDataGrid. The following code +shows the PHP for Home.php. The operative method is loadData(). +The rest is supporting code.

+ + +<?php +Prado::using('Example.Models.Person'); +class Home extends TPage +{ + private function loadData() + { + $sqlmap = $this->Application->getModule('SQLMap')->getClient(); + $this->personList->DataSource = $sqlmap->queryForList('SelectAll'); + $this->personList->dataBind(); + } + + public function onLoad($param) + { + if(!$this->IsPostBack) + $this->loadData(); + } +} +?> + + +

If we run this now, we'll get a list like the one shown the figure below.

+ class="figure" /> +
Figure 3: A quick-and-dirty Person List
+ +
\ No newline at end of file -- cgit v1.2.3