diff options
author | wei <> | 2006-07-14 09:20:45 +0000 |
---|---|---|
committer | wei <> | 2006-07-14 09:20:45 +0000 |
commit | 4b78404c20490a615459267426ce9e6737bf4485 (patch) | |
tree | be68ab7a2155980b05e5ab9f454e991e93007563 /demos/sqlmap-sample | |
parent | 143980b6dab8ad87c44518e5b7befb614fb83b85 (diff) |
Moving files.
Diffstat (limited to 'demos/sqlmap-sample')
21 files changed, 0 insertions, 449 deletions
diff --git a/demos/sqlmap-sample/index.php b/demos/sqlmap-sample/index.php deleted file mode 100644 index 43c0b436..00000000 --- a/demos/sqlmap-sample/index.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php
-
-$basePath=dirname(__FILE__);
-$frameworkPath=$basePath.'/../../framework/prado.php';
-$assetsPath=$basePath.'/assets';
-$runtimePath=$basePath.'/protected/runtime';
-
-if(!is_writable($assetsPath))
- die("Please make sure that the directory $assetsPath is writable by Web server process.");
-if(!is_writable($runtimePath))
- die("Please make sure that the directory $runtimePath is writable by Web server process.");
-
-require_once($frameworkPath);
-
-$application=new TApplication;
-$application->run();
-
-?>
\ No newline at end of file diff --git a/demos/sqlmap-sample/protected/application.xml b/demos/sqlmap-sample/protected/application.xml deleted file mode 100644 index 7cfb440f..00000000 --- a/demos/sqlmap-sample/protected/application.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?>
-<application id="Database" Mode="Debug">
- <paths>
- <alias id="Example" path="business-objects" />
- </paths>
- <modules>
- <module id="cache" class="System.Caching.TSqliteCache" />
- <module id="petshop-sqlmap"
- enableConfigCache="true"
- class="System.DataAccess.TSQLMap"
- configFile="Application.petshop-sqlmap" />
- <module id="person-sample"
- class="System.DataAccess.TSQLMap"
- configFile="Application.person-sqlmap" />
- </modules>
-</application>
\ No newline at end of file diff --git a/demos/sqlmap-sample/protected/business-objects/Person.php b/demos/sqlmap-sample/protected/business-objects/Person.php deleted file mode 100644 index ad9da4b3..00000000 --- a/demos/sqlmap-sample/protected/business-objects/Person.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php
-
-class Person
-{
- public $ID = -1;
- public $FirstName = '';
- public $LastName = '';
-
- public $WeightInKilograms = 0.0;
- public $HeightInMeters = 0.0;
-
- private $_birthDate = '';
-
- //setters and getter for BirthDate
- public function getBirthDate()
- {
- return $this->_birthDate;
- }
-
- public function setBirthDate($value)
- {
- $this->_birthDate = $value;
- }
-}
-
-?>
\ No newline at end of file diff --git a/demos/sqlmap-sample/protected/pages/Home.page b/demos/sqlmap-sample/protected/pages/Home.page deleted file mode 100644 index 6d059c7e..00000000 --- a/demos/sqlmap-sample/protected/pages/Home.page +++ /dev/null @@ -1,5 +0,0 @@ -<ul>
- <li><a href="index.php?page=crud1">Tutorial 1</a></li>
- <li><a href="index.php?page=crud2">Tutorial 2</a></li>
- <li><a href="index.php?page=ProductList">Product List</a></li>
-</ul>
\ No newline at end of file diff --git a/demos/sqlmap-sample/protected/pages/ProductList.page b/demos/sqlmap-sample/protected/pages/ProductList.page deleted file mode 100644 index 904d411d..00000000 --- a/demos/sqlmap-sample/protected/pages/ProductList.page +++ /dev/null @@ -1,9 +0,0 @@ -<h1>Database Examples</h1>
-<com:TRepeater id="productList">
- <prop:ItemTemplate>
- <div>
- Code: <%# $this->DataItem['productid'] %>
- Category: <%# $this->DataItem['category'] %>
- </div>
- </prop:ItemTemplate>
-</com:TRepeater>
\ No newline at end of file diff --git a/demos/sqlmap-sample/protected/pages/ProductList.php b/demos/sqlmap-sample/protected/pages/ProductList.php deleted file mode 100644 index a35c40ea..00000000 --- a/demos/sqlmap-sample/protected/pages/ProductList.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php
-
-class ProductList extends TPage
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $sqlmap = $this->Application->Modules['petshop-sqlmap'];
- $products = $sqlmap->queryForList('SelectAllProducts');
- $this->productList->setDataSource($products);
- $this->productList->dataBind();
- }
- }
-}
-
-?>
\ No newline at end of file diff --git a/demos/sqlmap-sample/protected/pages/crud1.page b/demos/sqlmap-sample/protected/pages/crud1.page deleted file mode 100644 index ce467ffa..00000000 --- a/demos/sqlmap-sample/protected/pages/crud1.page +++ /dev/null @@ -1,19 +0,0 @@ -<!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
-<head>
- <title>Person</title>
-</head>
-
-<body>
-
-<com:TForm>
- <h1>Person List</h1>
- <com:TDataGrid id="personList">
- <com:TBoundColumn DataField="BirthDate"
- HeaderText="Birth Date"/>
- </com:TDataGrid>
-</com:TForm>
-</body>
-</html>
\ No newline at end of file diff --git a/demos/sqlmap-sample/protected/pages/crud1.php b/demos/sqlmap-sample/protected/pages/crud1.php deleted file mode 100644 index 40733dc9..00000000 --- a/demos/sqlmap-sample/protected/pages/crud1.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php
-
-Prado::using('Example.Person');
-
-class crud1 extends TPage
-{
- private function loadData()
- {
- $sqlmap = $this->Application->Modules['person-sample'];
- $this->personList->DataSource = $sqlmap->queryForList('SelectAll');
- $this->personList->dataBind();
- }
-
- public function onLoad($param)
- {
- if(!$this->IsPostBack)
- $this->loadData();
- }
-}
-
-?>
\ No newline at end of file diff --git a/demos/sqlmap-sample/protected/pages/crud2.page b/demos/sqlmap-sample/protected/pages/crud2.page deleted file mode 100644 index 4d34e873..00000000 --- a/demos/sqlmap-sample/protected/pages/crud2.page +++ /dev/null @@ -1,36 +0,0 @@ -<!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
-<head>
- <title>Person</title>
-</head>
-
-<body>
-
-<com:TForm>
- <h1>Person List</h1>
- <com:TDataGrid id="personList"
- DataKeyField="ID"
- AutoGenerateColumns="False"
- OnEditCommand="editPerson"
- OnUpdateCommand="updatePerson"
- OnCancelCommand="refreshList"
- OnDeleteCommand="deletePerson">
- <com:TBoundColumn DataField="FirstName" HeaderText="First Name" />
- <com:TBoundColumn DataField="LastName" HeaderText="Last Name" />
- <com:TBoundColumn DataField="HeightInMeters" HeaderText="Height" />
- <com:TBoundColumn DataField="WeightInKilograms" HeaderText="Weight" />
-
- <com:TEditCommandColumn
- HeaderText="Edit"
- UpdateText="Save" />
- <com:TButtonColumn
- HeaderText="Delete"
- Text="Delete"
- CommandName="delete"/>
- </com:TDataGrid>
- <com:TButton Text="Add" OnClick="addNewPerson" />
-</com:TForm>
-</body>
-</html>
\ No newline at end of file diff --git a/demos/sqlmap-sample/protected/pages/crud2.php b/demos/sqlmap-sample/protected/pages/crud2.php deleted file mode 100644 index 46fe3893..00000000 --- a/demos/sqlmap-sample/protected/pages/crud2.php +++ /dev/null @@ -1,79 +0,0 @@ -<?php
-
-Prado::using('Example.Person');
-
-class crud2 extends TPage
-{
- private function sqlmap()
- {
- return $this->Application->Modules['person-sample'];
- }
-
- private function loadData()
- {
- $this->personList->DataSource =
- $this->sqlmap()->queryForList('SelectAll');
- $this->personList->dataBind();
- }
-
- public function onLoad($param)
- {
- if(!$this->IsPostBack)
- $this->loadData();
- }
-
- protected function editPerson($sender,$param)
- {
- $this->personList->EditItemIndex=$param->Item->ItemIndex;
- $this->loadData();
- }
-
- protected function deletePerson($sender, $param)
- {
- $id = $this->getKey($sender, $param);
-
- $this->sqlmap()->update("Delete", $id);
- $this->loadData();
- }
-
- protected function updatePerson($sender, $param)
- {
- $person = new Person();
- $person->FirstName = $this->getText($param, 0);
- $person->LastName = $this->getText($param, 1);
- $person->HeightInMeters = $this->getText($param, 2);
- $person->WeightInKilograms = $this->getText($param, 3);
- $person->ID = $this->getKey($sender, $param);
-
- $this->sqlmap()->update("Update", $person);
- $this->refreshList($sender, $param);
- }
-
- protected function addNewPerson($sender, $param)
- {
- $person = new Person;
- $person->FirstName = "-- New Person --";
- $this->sqlmap()->insert("Insert", $person);
-
- $this->loadData();;
- }
-
- protected function refreshList($sender, $param)
- {
- $this->personList->EditItemIndex=-1;
- $this->loadData();
- }
-
- private function getText($param, $index)
- {
- $item = $param->Item;
- return $item->Cells[$index]->Controls[0]->Text;
- }
-
- private function getKey($sender, $param)
- {
- return $sender->DataKeys[$param->Item->DataSourceIndex];
- }
-}
-
-?>
\ No newline at end of file diff --git a/demos/sqlmap-sample/protected/person-db/person.xml b/demos/sqlmap-sample/protected/person-db/person.xml deleted file mode 100644 index 4ffe44d9..00000000 --- a/demos/sqlmap-sample/protected/person-db/person.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?>
-<sqlMap>
-
- <select id="SelectAll" resultClass="Person">
- SELECT
- per_id as ID,
- per_first_name as FirstName,
- per_last_name as LastName,
- per_birth_date as BirthDate,
- per_weight_kg as WeightInKilograms,
- per_height_m as HeightInMeters
- FROM
- person
- </select>
-
-</sqlMap>
\ No newline at end of file diff --git a/demos/sqlmap-sample/protected/person-db/personHelper.xml b/demos/sqlmap-sample/protected/person-db/personHelper.xml deleted file mode 100644 index ea2d4302..00000000 --- a/demos/sqlmap-sample/protected/person-db/personHelper.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?>
-
-<sqlMap Name="PersonHelper">
-
- <select id="Select" parameterClass="int" resultClass="Person">
- select
- PER_ID as ID,
- PER_FIRST_NAME as FirstName,
- PER_LAST_NAME as LastName,
- PER_BIRTH_DATE as BirthDate,
- PER_WEIGHT_KG as WeightInKilograms,
- PER_HEIGHT_M as HeightInMeters
- from PERSON
- WHERE
- PER_ID = #value#
- </select>
-
- <insert id="Insert" parameterClass="Person">
- insert into PERSON
- (PER_ID, PER_FIRST_NAME, PER_LAST_NAME,
- PER_BIRTH_DATE, PER_WEIGHT_KG, PER_HEIGHT_M)
- values
- (#ID#, #FirstName#, #LastName#,
- #BirthDate#, #WeightInKilograms#, #HeightInMeters#)
- </insert>
-
- <update id="Update" parameterClass="Person">
- update PERSON set
- PER_FIRST_NAME = #FirstName#,
- PER_LAST_NAME = #LastName#,
- PER_BIRTH_DATE = #BirthDate#,
- PER_WEIGHT_KG = #WeightInKilograms#,
- PER_HEIGHT_M = #HeightInMeters#
- where PER_ID = #ID#
- </update>
-
- <delete id="Delete" parameterClass="int">
- delete from PERSON
- where PER_ID = #value#
- </delete>
-
-</sqlMap>
diff --git a/demos/sqlmap-sample/protected/person-db/test.db b/demos/sqlmap-sample/protected/person-db/test.db Binary files differdeleted file mode 100644 index a40c91fe..00000000 --- a/demos/sqlmap-sample/protected/person-db/test.db +++ /dev/null diff --git a/demos/sqlmap-sample/protected/person-sqlmap.xml b/demos/sqlmap-sample/protected/person-sqlmap.xml deleted file mode 100644 index 8d5319e8..00000000 --- a/demos/sqlmap-sample/protected/person-sqlmap.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?>
-<sqlMapConfig>
-
- <provider class="TAdodbProvider">
- <datasource driver="sqlite" host="protected/person-db/test.db" />
- </provider>
-
- <sqlMaps>
- <sqlMap resource="person-db/person.xml"/>
- <sqlMap resource="person-db/personHelper.xml"/>
- </sqlMaps>
-
-</sqlMapConfig>
\ No newline at end of file diff --git a/demos/sqlmap-sample/protected/petshop-db/petshop.db b/demos/sqlmap-sample/protected/petshop-db/petshop.db Binary files differdeleted file mode 100644 index 9a4404df..00000000 --- a/demos/sqlmap-sample/protected/petshop-db/petshop.db +++ /dev/null diff --git a/demos/sqlmap-sample/protected/petshop-db/products.xml b/demos/sqlmap-sample/protected/petshop-db/products.xml deleted file mode 100644 index 3c2899a7..00000000 --- a/demos/sqlmap-sample/protected/petshop-db/products.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?>
-<sqlmap>
-
- <cacheModel id="product-cache" implementation="basic">
- <!-- cache data for 60 seconds -->
- <property name="expiry" value="60" />
- </cacheModel>
-
- <select id="SelectAllProducts" cacheModel="product-cache" >
- SELECT *
- FROM
- product
- </select>
-
-</sqlmap>
\ No newline at end of file diff --git a/demos/sqlmap-sample/protected/petshop-sqlmap.xml b/demos/sqlmap-sample/protected/petshop-sqlmap.xml deleted file mode 100644 index f77fe2b7..00000000 --- a/demos/sqlmap-sample/protected/petshop-sqlmap.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?>
-<sqlMapConfig>
-
- <provider class="TAdodbProvider">
- <datasource driver="sqlite" host="protected/petshop-db/petshop.db" />
- </provider>
-
- <sqlMaps>
- <sqlMap resource="petshop-db/products.xml"/>
- </sqlMaps>
-
-</sqlMapConfig>
\ No newline at end of file diff --git a/demos/sqlmap-sample/tests/PersonTest.php b/demos/sqlmap-sample/tests/PersonTest.php deleted file mode 100644 index c40bffa0..00000000 --- a/demos/sqlmap-sample/tests/PersonTest.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php
-
-class PersonTest extends UnitTestCase
-{
- function testPersonList()
- {
- //try it
- $people = TMapper::instance()->queryForList("SelectAll");
-
- //test it
- $this->assertNotNull($people, "Person list is not returned");
- $this->assertTrue(count($people) > 0, "Person list is empty");
- $person = $people[0];
- $this->assertNotNull($person, "Person not returned");
- }
-
- function testPersonUpdate()
- {
- $expect = "wei";
- $edited = "Nah";
-
- //get it;
- $person = TMapper::instance()->queryForObject("Select", 1);
-
- //test it
- $this->assertNotNull($person);
- $this->assertEqual($expect, $person->FirstName);
-
- //change it
- $person->FirstName = $edited;
- TMapper::instance()->update("Update", $person);
-
- //get it again
- $person = TMapper::instance()->queryForObject("Select", 1);
-
- //test it
- $this->assertEqual($edited, $person->FirstName);
-
- //change it back
- $person->FirstName = $expect;
- TMapper::instance()->update("Update", $person);
- }
-
- function testPersonDelete()
- {
- //insert it
- $person = new Person;
- $person->ID = -1;
- TMapper::instance()->insert("Insert", $person);
-
- //delte it
- $count = TMapper::instance()->delete("Delete", -1);
- $this->assertEqual(1, $count);
- }
-}
-
-?>
\ No newline at end of file diff --git a/demos/sqlmap-sample/tests/readme.txt b/demos/sqlmap-sample/tests/readme.txt deleted file mode 100644 index c0d0afdb..00000000 --- a/demos/sqlmap-sample/tests/readme.txt +++ /dev/null @@ -1 +0,0 @@ -The ''Data'' directory and ''Data/test.db'' must be writable by PHP for SQLite database to work.
\ No newline at end of file diff --git a/demos/sqlmap-sample/tests/run_tests.php b/demos/sqlmap-sample/tests/run_tests.php deleted file mode 100644 index 843d0a79..00000000 --- a/demos/sqlmap-sample/tests/run_tests.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php
-
-//define simple test location
-define('SIMPLE_TEST', realpath('../../../tests/UnitTests/simpletest'));
-
-//define prado framework location
-define('PRADO', realpath('../../../framework'));
-
-//define directory that contains business objects
-define('MY_MODELS', realpath('../protected/business-objects'));
-
-require_once(SIMPLE_TEST.'/unit_tester.php');
-require_once(SIMPLE_TEST.'/reporter.php');
-require_once(PRADO.'/prado.php');
-require_once(MY_MODELS.'/Person.php');
-
-//supress strict warnings
-error_reporting(E_ALL);
-
-//import Data mapper
-Prado::using('System.DataAccess.SQLMap.TMapper');
-
-//Add tests
-$test = new GroupTest('SQLMap Tutorial tests');
-$test->addTestFile('PersonTest.php');
-if(SimpleReporter::inCli())
- $reporter = new TextReporter();
-else
- $reporter = new HtmlReporter();
-$test->run($reporter);
-
-
-?>
\ No newline at end of file diff --git a/demos/sqlmap-sample/tests/sqlmap.xml b/demos/sqlmap-sample/tests/sqlmap.xml deleted file mode 100644 index 3968fab4..00000000 --- a/demos/sqlmap-sample/tests/sqlmap.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?>
-<sqlMapConfig>
-
- <provider class="TAdodbProvider">
- <datasource driver="sqlite" host="../protected/person-db/test.db" />
- </provider>
-
- <sqlMaps>
- <sqlMap resource="../protected/person-db/person.xml"/>
- <sqlMap resource="../protected/person-db/personHelper.xml"/>
- </sqlMaps>
-
-</sqlMapConfig>
\ No newline at end of file |