View difference between Paste ID: AP5wwQNP and uHS2WDaf
SHOW: | | - or go back to the newest paste.
1-
<?php
1+
class NewCars extends Nette\Object
2
{
3-
class Model extends Nette\Object
3+
	/** @var DibiConnection */
4
	private $db;
5-
	/** @var Nette\Database\Table\Selection */
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-
	public function getCars()
15+
16
        
17-
            return $this->db
17+
        public function find($id = 0)
18-
                        ->select('*')
18+
19-
                        ->from('nove_vozy');         
19+
            return $this->db->select('*')->from('nove_vozy')
20
		->where('id = %s', $id)
21
		->fetch();     
22-
        public function getCar($id = 0)
22+
23
}
24-
            return $this->db
24+
25-
                        ->select('*')
25+
26-
                        ->from('nove_vozy')->where('id = %s', $id);
26+
# config
27-
                     
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
}