summaryrefslogtreecommitdiff
path: root/demos/address-book/protected/pages/AddressProvider.php
diff options
context:
space:
mode:
authorwei <>2007-01-17 11:55:40 +0000
committerwei <>2007-01-17 11:55:40 +0000
commit912dc30b43330a3e99a3e1f947ff14de108a3701 (patch)
tree064a66120c95b043de9f9d56fb52d3e66bfe3e81 /demos/address-book/protected/pages/AddressProvider.php
parent3dc598bc7c2604e24b9e0be1189d9d78b43737ea (diff)
Add address-book flex demo
Diffstat (limited to 'demos/address-book/protected/pages/AddressProvider.php')
-rw-r--r--demos/address-book/protected/pages/AddressProvider.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/demos/address-book/protected/pages/AddressProvider.php b/demos/address-book/protected/pages/AddressProvider.php
new file mode 100644
index 00000000..bbfedd1b
--- /dev/null
+++ b/demos/address-book/protected/pages/AddressProvider.php
@@ -0,0 +1,52 @@
+<?php
+
+Prado::using('Application.pages.AddressRecord');
+/**
+ * @author Wei Zhuo <weizho[at]gmail[dot]com>
+ * @version $Id$
+ * @since 3.1
+ */
+class AddressProvider
+{
+ /**
+ * @return AddressRecord[]
+ * @soapmethod
+ */
+ public function getAllAddress()
+ {
+ return AddressRecord::finder()->findAll();
+ }
+
+
+ /**
+ * Update address if $data->id > 0, otherwise add new address.
+ * @param AddressRecord $data
+ * @return boolean
+ * @soapmethod
+ */
+ public function saveAddress($data)
+ {
+ $finder = AddressRecord::finder();
+ if($data->id > 0 && $address=$finder->findByPk($data->id))
+ {
+ return $address->copyFrom($data)->save();
+ }
+ else
+ {
+ $data->id = null; //nullify the id
+ return $data->save();
+ }
+ }
+
+ /**
+ * @param integer $id
+ * @return integer number of records deleted
+ * @soapmethod
+ */
+ public function deleteAddress($id)
+ {
+ return AddressRecord::finder()->deleteByPk($id);
+ }
+}
+
+?> \ No newline at end of file