2009-02-15 Google Map の地図を入れた住所録(symfony の CRUD)のサンプル ================================================================================ 課題とは違い、詳細画面に GoogleMap を表示しています。 ■schema.yml (一部) --- : address: _attributes: { phpName: Address } id: name: varchar(50) address: longvarchar email: longvarchar comment: longvarchar created_at: : --- ■action.class.php --- forward('admin', 'list'); } public function executeList() { $this->addresss = AddressPeer::doSelect(new Criteria()); } public function executeShow() { $this->address = AddressPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($this->address); $this->geocoding = $this->getGeocoding($this->address); } private function getGeocoding($address) { $url = "http://www.geocoding.jp/api/?q={$address->getAddress()}"; $geocoding = simplexml_load_file($url); $this->forward404Unless($geocoding); $this->forward404If(isset($geocoding->error)); return $geocoding; } public function executeCreate() { $this->address = new Address(); $this->setTemplate('edit'); } public function executeEdit() { $this->address = AddressPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($this->address); } public function executeUpdate() { if (!$this->getRequestParameter('id')) { $address = new Address(); } else { $address = AddressPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($address); } $address->setId($this->getRequestParameter('id')); $address->setName($this->getRequestParameter('name')); $address->setAddress($this->getRequestParameter('address')); $address->setEmail($this->getRequestParameter('email')); $address->setComment($this->getRequestParameter('comment')); $address->save(); return $this->redirect('admin/show?id='.$address->getId()); } public function executeDelete() { $address = AddressPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($address); $address->delete(); return $this->redirect('admin/list'); } } --- ■layout.php --- getRaw('sf_content') ?> --- ■showSuccess.php ---
Id: getId() ?>
Name: getName() ?>
Address: getAddress() ?>
Email: getEmail() ?>
Comment: getComment() ?>
Created at: getCreatedAt() ?>

getId()) ?>   --- 以上