From ea9e7eb535b460218b693d4e5fec80297eb3e360 Mon Sep 17 00:00:00 2001
From: wei <>
Date: Thu, 3 May 2007 01:37:21 +0000
Subject: Add northwind db demo.
---
demos/northwind-db/protected/.htaccess | 1 +
demos/northwind-db/protected/application.xml | 20 +++++++
demos/northwind-db/protected/data/Northwind.db | Bin 0 -> 583680 bytes
demos/northwind-db/protected/database/Category.php | 26 +++++++++
demos/northwind-db/protected/database/Customer.php | 33 ++++++++++++
demos/northwind-db/protected/database/Employee.php | 48 +++++++++++++++++
demos/northwind-db/protected/database/Order.php | 42 +++++++++++++++
.../protected/database/OrderDetail.php | 27 ++++++++++
demos/northwind-db/protected/database/Product.php | 36 +++++++++++++
demos/northwind-db/protected/database/Region.php | 24 +++++++++
demos/northwind-db/protected/database/Shipper.php | 25 +++++++++
demos/northwind-db/protected/database/Supplier.php | 34 ++++++++++++
.../northwind-db/protected/database/Territory.php | 60 +++++++++++++++++++++
demos/northwind-db/protected/pages/Home.page | 12 +++++
demos/northwind-db/protected/pages/Home.php | 28 ++++++++++
demos/northwind-db/protected/pages/northwind.gif | Bin 0 -> 25177 bytes
16 files changed, 416 insertions(+)
create mode 100644 demos/northwind-db/protected/.htaccess
create mode 100644 demos/northwind-db/protected/application.xml
create mode 100644 demos/northwind-db/protected/data/Northwind.db
create mode 100644 demos/northwind-db/protected/database/Category.php
create mode 100644 demos/northwind-db/protected/database/Customer.php
create mode 100644 demos/northwind-db/protected/database/Employee.php
create mode 100644 demos/northwind-db/protected/database/Order.php
create mode 100644 demos/northwind-db/protected/database/OrderDetail.php
create mode 100644 demos/northwind-db/protected/database/Product.php
create mode 100644 demos/northwind-db/protected/database/Region.php
create mode 100644 demos/northwind-db/protected/database/Shipper.php
create mode 100644 demos/northwind-db/protected/database/Supplier.php
create mode 100644 demos/northwind-db/protected/database/Territory.php
create mode 100644 demos/northwind-db/protected/pages/Home.page
create mode 100644 demos/northwind-db/protected/pages/Home.php
create mode 100644 demos/northwind-db/protected/pages/northwind.gif
(limited to 'demos/northwind-db/protected')
diff --git a/demos/northwind-db/protected/.htaccess b/demos/northwind-db/protected/.htaccess
new file mode 100644
index 00000000..3418e55a
--- /dev/null
+++ b/demos/northwind-db/protected/.htaccess
@@ -0,0 +1 @@
+deny from all
\ No newline at end of file
diff --git a/demos/northwind-db/protected/application.xml b/demos/northwind-db/protected/application.xml
new file mode 100644
index 00000000..3ac9c67c
--- /dev/null
+++ b/demos/northwind-db/protected/application.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/demos/northwind-db/protected/data/Northwind.db b/demos/northwind-db/protected/data/Northwind.db
new file mode 100644
index 00000000..9d6b08b4
Binary files /dev/null and b/demos/northwind-db/protected/data/Northwind.db differ
diff --git a/demos/northwind-db/protected/database/Category.php b/demos/northwind-db/protected/database/Category.php
new file mode 100644
index 00000000..05fa7ed0
--- /dev/null
+++ b/demos/northwind-db/protected/database/Category.php
@@ -0,0 +1,26 @@
+ array(self::HAS_MANY, 'Product'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
+?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/database/Customer.php b/demos/northwind-db/protected/database/Customer.php
new file mode 100644
index 00000000..356dd02f
--- /dev/null
+++ b/demos/northwind-db/protected/database/Customer.php
@@ -0,0 +1,33 @@
+ array(self::HAS_MANY, 'Order'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
+?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/database/Employee.php b/demos/northwind-db/protected/database/Employee.php
new file mode 100644
index 00000000..7a678f57
--- /dev/null
+++ b/demos/northwind-db/protected/database/Employee.php
@@ -0,0 +1,48 @@
+ array(self::HAS_MANY, 'Territory', 'EmployeeTerritories'),
+ 'Orders' => array(self::HAS_MANY, 'Order'),
+
+ //parent children relationship
+ 'Subordinates' => array(self::HAS_MANY, 'Employee'),
+ 'Superior' => array(self::BELONGS_TO, 'Employee')
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
+?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/database/Order.php b/demos/northwind-db/protected/database/Order.php
new file mode 100644
index 00000000..fa865e61
--- /dev/null
+++ b/demos/northwind-db/protected/database/Order.php
@@ -0,0 +1,42 @@
+ array(self::HAS_MANY, 'OrderDetail'),
+ 'Customer' => array(self::BELONGS_TO, 'Customer'),
+ 'Shipper' => array(self::BELONGS_TO, 'Shipper'),
+ 'Employee' => array(self::BELONGS_TO, 'Employee'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
+?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/database/OrderDetail.php b/demos/northwind-db/protected/database/OrderDetail.php
new file mode 100644
index 00000000..9415e33e
--- /dev/null
+++ b/demos/northwind-db/protected/database/OrderDetail.php
@@ -0,0 +1,27 @@
+ array(self::BELONGS_TO, 'Product'),
+ 'Order' => array(self::BELONGS_TO, 'Order'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
+?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/database/Product.php b/demos/northwind-db/protected/database/Product.php
new file mode 100644
index 00000000..75d01c02
--- /dev/null
+++ b/demos/northwind-db/protected/database/Product.php
@@ -0,0 +1,36 @@
+ array(self::BELONGS_TO, 'Supplier'),
+ 'Category' => array(self::BELONGS_TO, 'Category'),
+ 'OrderDetails' => array(self::HAS_MANY, 'OrderDetail'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
+?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/database/Region.php b/demos/northwind-db/protected/database/Region.php
new file mode 100644
index 00000000..2afa3501
--- /dev/null
+++ b/demos/northwind-db/protected/database/Region.php
@@ -0,0 +1,24 @@
+ array(self::HAS_MANY, 'Territory')
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
+?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/database/Shipper.php b/demos/northwind-db/protected/database/Shipper.php
new file mode 100644
index 00000000..6ac8a929
--- /dev/null
+++ b/demos/northwind-db/protected/database/Shipper.php
@@ -0,0 +1,25 @@
+ array(self::HAS_MANY, 'Order'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
+?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/database/Supplier.php b/demos/northwind-db/protected/database/Supplier.php
new file mode 100644
index 00000000..537daade
--- /dev/null
+++ b/demos/northwind-db/protected/database/Supplier.php
@@ -0,0 +1,34 @@
+ array(self::HAS_MANY, 'Product')
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
+?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/database/Territory.php b/demos/northwind-db/protected/database/Territory.php
new file mode 100644
index 00000000..4da0ff46
--- /dev/null
+++ b/demos/northwind-db/protected/database/Territory.php
@@ -0,0 +1,60 @@
+ array(self::BELONGS_TO, 'Region'),
+ 'Employees' => array(self::HAS_MANY, 'Employee', 'EmployeeTerritories')
+ );
+
+ /**
+ * @return Region
+ */
+ public function getRegion()
+ {
+ //lazy load the region
+ if($this->_region===null)
+ $this->_region = Region::finder()->findByPk($this->RegionID);
+ return $this->_region;
+ }
+
+ public function setRegion($value)
+ {
+ $this->_region=$value;
+ }
+
+ /**
+ * @return Employee[]
+ */
+ public function getEmployees()
+ {
+ //lazy load
+ if($this->_employees==null)
+ $this->setEmployees($this->withEmployees()->findByPk($this->TerritoryID)->getEmployees());
+ return $this->_employees;
+ }
+
+ public function setEmployees($value)
+ {
+ //ensure TList
+ $this->_employees = $value instanceof TList ? $value : new TList($value);
+ }
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
+?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/pages/Home.page b/demos/northwind-db/protected/pages/Home.page
new file mode 100644
index 00000000..e2c3668e
--- /dev/null
+++ b/demos/northwind-db/protected/pages/Home.page
@@ -0,0 +1,12 @@
+
+
+
+Welcome to PRADO!
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/demos/northwind-db/protected/pages/Home.php b/demos/northwind-db/protected/pages/Home.php
new file mode 100644
index 00000000..06035069
--- /dev/null
+++ b/demos/northwind-db/protected/pages/Home.php
@@ -0,0 +1,28 @@
+getRecordClassList(Prado::getPathOfNamespace('Application.database.*'));
+ $this->class_list->dataSource = $classes;
+ $this->class_list->dataBind();
+ }
+
+ protected function getRecordClassList($directory)
+ {
+ $list=array();
+ $folder=@opendir($directory);
+ while($entry=@readdir($folder))
+ {
+ if($entry[0]==='.')
+ continue;
+ else if(is_file($directory.'/'.$entry))
+ $list[] = str_replace('.php', '', $entry);
+ }
+ closedir($folder);
+ return $list;
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/pages/northwind.gif b/demos/northwind-db/protected/pages/northwind.gif
new file mode 100644
index 00000000..34e1f2ed
Binary files /dev/null and b/demos/northwind-db/protected/pages/northwind.gif differ
--
cgit v1.2.3