예제 #1
0
 public function fetchAll()
 {
     $resultSet = $this->getDbTable()->fetchAll();
     $entries = array();
     foreach ($resultSet as $row) {
         $entry = new Default_Model_Product();
         $entry->setId($row->id)->setCode($row->code)->setName($row->name)->setDescription($row->description)->setListPrice($row->listPrice)->setCreated($row->created);
         $entries[] = $entry;
     }
     return $entries;
 }
 public function updateAction()
 {
     $request = $this->getRequest();
     $form = new Default_Form_Product();
     $product = new Default_Model_Product();
     // Get Product Id
     $id = $request->getParam("id", 1);
     if ($request->isPost() && $form->isValid($request->getPost())) {
         $model = new Default_Model_Product($form->getValues());
         $model->setId($id);
         $model->save();
         return $this->_helper->redirector('index');
     }
     // Get the Product Data by Id
     $data = $product->find($id);
     // Add Product Data to Form
     $form->populate($data->toArray());
     $this->view->form = $form;
 }