HosipLan

Untitled

Feb 6th, 2012
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class NewCars extends Nette\Object
  2. {
  3.     /** @var DibiConnection */
  4.     private $db;
  5.  
  6.     public function __construct(DibiConnection $db)
  7.     {
  8.         $this->db = $db;
  9.     }
  10.  
  11.     public function findAll()
  12.     {
  13.         return $this->db->select('*')->from('nove_vozy')
  14.             ->fetchAll();
  15.     }
  16.        
  17.         public function find($id = 0)
  18.         {
  19.             return $this->db->select('*')->from('nove_vozy')
  20.         ->where('id = %s', $id)
  21.         ->fetch();    
  22.         }
  23. }
  24.  
  25.  
  26. # config
  27.  
  28.  
  29. services:
  30.         newCars:
  31.             class: NewCars(@db)
  32.  
  33.  
  34. # presenter
  35.  
  36.  
  37. class HomepagePresenter extends BasePresenter
  38. {
  39.         private $newCars;
  40.    
  41.         protected function startup()
  42.         {
  43.             parent::startup();
  44.             $this->newCars = $this->context->newCars;
  45.         }
  46.        
  47.     public function renderDefault()
  48.     {
  49.                 $this->template->newCars = $this->newCars->findAll();
  50.     }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment