From 3d3f8d3832921f99daf8ce1953304763c2e76c62 Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 14 Apr 2006 06:22:09 +0000 Subject: Importing SQLMap + sample + docs. --- demos/sqlmap-sample/index.php | 18 +++++ demos/sqlmap-sample/protected/application.xml | 16 +++++ .../protected/business-objects/Person.php | 26 +++++++ demos/sqlmap-sample/protected/pages/Home.page | 5 ++ .../sqlmap-sample/protected/pages/ProductList.page | 9 +++ .../sqlmap-sample/protected/pages/ProductList.php | 18 +++++ demos/sqlmap-sample/protected/pages/crud1.page | 19 +++++ demos/sqlmap-sample/protected/pages/crud1.php | 21 ++++++ demos/sqlmap-sample/protected/pages/crud2.page | 36 ++++++++++ demos/sqlmap-sample/protected/pages/crud2.php | 79 +++++++++++++++++++++ demos/sqlmap-sample/protected/person-db/person.xml | 16 +++++ .../protected/person-db/personHelper.xml | 42 +++++++++++ demos/sqlmap-sample/protected/person-db/test.db | Bin 0 -> 5120 bytes demos/sqlmap-sample/protected/person-sqlmap.xml | 13 ++++ .../sqlmap-sample/protected/petshop-db/petshop.db | Bin 0 -> 61440 bytes .../protected/petshop-db/products.xml | 10 +++ demos/sqlmap-sample/protected/petshop-sqlmap.xml | 12 ++++ .../protected/runtime/application.xml/config.cache | Bin 0 -> 2101 bytes .../protected/runtime/application.xml/global.cache | 1 + .../protected/runtime/application.xml/sqlite.cache | Bin 0 -> 19456 bytes demos/sqlmap-sample/tests/PersonTest.php | 57 +++++++++++++++ demos/sqlmap-sample/tests/readme.txt | 1 + demos/sqlmap-sample/tests/run_tests.php | 33 +++++++++ demos/sqlmap-sample/tests/sqlmap.xml | 13 ++++ 24 files changed, 445 insertions(+) create mode 100644 demos/sqlmap-sample/index.php create mode 100644 demos/sqlmap-sample/protected/application.xml create mode 100644 demos/sqlmap-sample/protected/business-objects/Person.php create mode 100644 demos/sqlmap-sample/protected/pages/Home.page create mode 100644 demos/sqlmap-sample/protected/pages/ProductList.page create mode 100644 demos/sqlmap-sample/protected/pages/ProductList.php create mode 100644 demos/sqlmap-sample/protected/pages/crud1.page create mode 100644 demos/sqlmap-sample/protected/pages/crud1.php create mode 100644 demos/sqlmap-sample/protected/pages/crud2.page create mode 100644 demos/sqlmap-sample/protected/pages/crud2.php create mode 100644 demos/sqlmap-sample/protected/person-db/person.xml create mode 100644 demos/sqlmap-sample/protected/person-db/personHelper.xml create mode 100644 demos/sqlmap-sample/protected/person-db/test.db create mode 100644 demos/sqlmap-sample/protected/person-sqlmap.xml create mode 100644 demos/sqlmap-sample/protected/petshop-db/petshop.db create mode 100644 demos/sqlmap-sample/protected/petshop-db/products.xml create mode 100644 demos/sqlmap-sample/protected/petshop-sqlmap.xml create mode 100644 demos/sqlmap-sample/protected/runtime/application.xml/config.cache create mode 100644 demos/sqlmap-sample/protected/runtime/application.xml/global.cache create mode 100644 demos/sqlmap-sample/protected/runtime/application.xml/sqlite.cache create mode 100644 demos/sqlmap-sample/tests/PersonTest.php create mode 100644 demos/sqlmap-sample/tests/readme.txt create mode 100644 demos/sqlmap-sample/tests/run_tests.php create mode 100644 demos/sqlmap-sample/tests/sqlmap.xml (limited to 'demos') diff --git a/demos/sqlmap-sample/index.php b/demos/sqlmap-sample/index.php new file mode 100644 index 00000000..43c0b436 --- /dev/null +++ b/demos/sqlmap-sample/index.php @@ -0,0 +1,18 @@ +run(); + +?> \ No newline at end of file diff --git a/demos/sqlmap-sample/protected/application.xml b/demos/sqlmap-sample/protected/application.xml new file mode 100644 index 00000000..7cfb440f --- /dev/null +++ b/demos/sqlmap-sample/protected/application.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + \ 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 new file mode 100644 index 00000000..ad9da4b3 --- /dev/null +++ b/demos/sqlmap-sample/protected/business-objects/Person.php @@ -0,0 +1,26 @@ +_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 new file mode 100644 index 00000000..6d059c7e --- /dev/null +++ b/demos/sqlmap-sample/protected/pages/Home.page @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/demos/sqlmap-sample/protected/pages/ProductList.page b/demos/sqlmap-sample/protected/pages/ProductList.page new file mode 100644 index 00000000..904d411d --- /dev/null +++ b/demos/sqlmap-sample/protected/pages/ProductList.page @@ -0,0 +1,9 @@ +

Database Examples

+ + +
+ Code: <%# $this->DataItem['productid'] %> + Category: <%# $this->DataItem['category'] %> +
+
+
\ No newline at end of file diff --git a/demos/sqlmap-sample/protected/pages/ProductList.php b/demos/sqlmap-sample/protected/pages/ProductList.php new file mode 100644 index 00000000..a35c40ea --- /dev/null +++ b/demos/sqlmap-sample/protected/pages/ProductList.php @@ -0,0 +1,18 @@ +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 new file mode 100644 index 00000000..ce467ffa --- /dev/null +++ b/demos/sqlmap-sample/protected/pages/crud1.page @@ -0,0 +1,19 @@ + + + + + Person + + + + + +

Person List

+ + + +
+ + \ No newline at end of file diff --git a/demos/sqlmap-sample/protected/pages/crud1.php b/demos/sqlmap-sample/protected/pages/crud1.php new file mode 100644 index 00000000..40733dc9 --- /dev/null +++ b/demos/sqlmap-sample/protected/pages/crud1.php @@ -0,0 +1,21 @@ +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 new file mode 100644 index 00000000..4d34e873 --- /dev/null +++ b/demos/sqlmap-sample/protected/pages/crud2.page @@ -0,0 +1,36 @@ + + + + + Person + + + + + +

Person List

+ + + + + + + + + + +
+ + \ No newline at end of file diff --git a/demos/sqlmap-sample/protected/pages/crud2.php b/demos/sqlmap-sample/protected/pages/crud2.php new file mode 100644 index 00000000..46fe3893 --- /dev/null +++ b/demos/sqlmap-sample/protected/pages/crud2.php @@ -0,0 +1,79 @@ +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 new file mode 100644 index 00000000..4ffe44d9 --- /dev/null +++ b/demos/sqlmap-sample/protected/person-db/person.xml @@ -0,0 +1,16 @@ + + + + + + \ 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 new file mode 100644 index 00000000..ea2d4302 --- /dev/null +++ b/demos/sqlmap-sample/protected/person-db/personHelper.xml @@ -0,0 +1,42 @@ + + + + + + + + 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#) + + + + 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# + + + + delete from PERSON + where PER_ID = #value# + + + diff --git a/demos/sqlmap-sample/protected/person-db/test.db b/demos/sqlmap-sample/protected/person-db/test.db new file mode 100644 index 00000000..a40c91fe Binary files /dev/null and b/demos/sqlmap-sample/protected/person-db/test.db differ diff --git a/demos/sqlmap-sample/protected/person-sqlmap.xml b/demos/sqlmap-sample/protected/person-sqlmap.xml new file mode 100644 index 00000000..8d5319e8 --- /dev/null +++ b/demos/sqlmap-sample/protected/person-sqlmap.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ 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 new file mode 100644 index 00000000..9a4404df Binary files /dev/null and b/demos/sqlmap-sample/protected/petshop-db/petshop.db differ diff --git a/demos/sqlmap-sample/protected/petshop-db/products.xml b/demos/sqlmap-sample/protected/petshop-db/products.xml new file mode 100644 index 00000000..bf1453b2 --- /dev/null +++ b/demos/sqlmap-sample/protected/petshop-db/products.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/demos/sqlmap-sample/protected/petshop-sqlmap.xml b/demos/sqlmap-sample/protected/petshop-sqlmap.xml new file mode 100644 index 00000000..f77fe2b7 --- /dev/null +++ b/demos/sqlmap-sample/protected/petshop-sqlmap.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/demos/sqlmap-sample/protected/runtime/application.xml/config.cache b/demos/sqlmap-sample/protected/runtime/application.xml/config.cache new file mode 100644 index 00000000..ce7bd76a Binary files /dev/null and b/demos/sqlmap-sample/protected/runtime/application.xml/config.cache differ diff --git a/demos/sqlmap-sample/protected/runtime/application.xml/global.cache b/demos/sqlmap-sample/protected/runtime/application.xml/global.cache new file mode 100644 index 00000000..b35e9768 --- /dev/null +++ b/demos/sqlmap-sample/protected/runtime/application.xml/global.cache @@ -0,0 +1 @@ +a:1:{s:35:"prado:securitymanager:validationkey";s:32:"e632288aebf1e51c0447ab4b701f1aa7";} \ No newline at end of file diff --git a/demos/sqlmap-sample/protected/runtime/application.xml/sqlite.cache b/demos/sqlmap-sample/protected/runtime/application.xml/sqlite.cache new file mode 100644 index 00000000..be9b9cc0 Binary files /dev/null and b/demos/sqlmap-sample/protected/runtime/application.xml/sqlite.cache differ diff --git a/demos/sqlmap-sample/tests/PersonTest.php b/demos/sqlmap-sample/tests/PersonTest.php new file mode 100644 index 00000000..c40bffa0 --- /dev/null +++ b/demos/sqlmap-sample/tests/PersonTest.php @@ -0,0 +1,57 @@ +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 new file mode 100644 index 00000000..c0d0afdb --- /dev/null +++ b/demos/sqlmap-sample/tests/readme.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 00000000..843d0a79 --- /dev/null +++ b/demos/sqlmap-sample/tests/run_tests.php @@ -0,0 +1,33 @@ +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 new file mode 100644 index 00000000..3968fab4 --- /dev/null +++ b/demos/sqlmap-sample/tests/sqlmap.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3