From 912dc30b43330a3e99a3e1f947ff14de108a3701 Mon Sep 17 00:00:00 2001 From: wei <> Date: Wed, 17 Jan 2007 11:55:40 +0000 Subject: Add address-book flex demo --- .../protected/pages/AddressProvider.php | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 demos/address-book/protected/pages/AddressProvider.php (limited to 'demos/address-book/protected/pages/AddressProvider.php') 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 @@ + + * @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 -- cgit v1.2.3