Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. <?php
  2.  
  3. class Application_Model_DbTable_Projects extends Zend_Db_Table_Abstract
  4. {
  5.  
  6.     protected $_name = 'projects';
  7.  
  8.     public function getProject($id)
  9.     {
  10.         $id = (int)$id;
  11.         $row = $this->fetchRow('id = ' . $id);
  12.        
  13.         if (!$row){
  14.             throw new Exception("Could not find row $id");
  15.     }
  16.        
  17.     return $row->toArray();
  18.     }
  19.    
  20.     public function addProject($id, $name, $price, $description)
  21.     {
  22.         $data = array(
  23.             'id'          => $id,
  24.             'name'        => $name,
  25.             'price'       => $price,
  26.             'description' => $description,
  27.         );
  28.        
  29.         $this->insert($data);
  30.     }
  31.    
  32.     public function updateProject($id, $name, $price, $description)
  33.     {
  34.         $data = array(
  35.             'name'        => $name,
  36.             'price'       => $price,
  37.             'description' => $description,
  38.         );
  39.        
  40.         $this->update($data, 'id = '. (int)$id);
  41.     }
  42.    
  43.     public function deleteProject($id)
  44.     {
  45.         $this->delete('id =' . (int)$id);
  46.     }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement