Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class NewCars extends Nette\Object
- {
- /** @var DibiConnection */
- private $db;
- public function __construct(DibiConnection $db)
- {
- $this->db = $db;
- }
- public function findAll()
- {
- return $this->db->select('*')->from('nove_vozy')
- ->fetchAll();
- }
- public function find($id = 0)
- {
- return $this->db->select('*')->from('nove_vozy')
- ->where('id = %s', $id)
- ->fetch();
- }
- }
- # config
- services:
- newCars:
- class: NewCars(@db)
- # presenter
- class HomepagePresenter extends BasePresenter
- {
- private $newCars;
- protected function startup()
- {
- parent::startup();
- $this->newCars = $this->context->newCars;
- }
- public function renderDefault()
- {
- $this->template->newCars = $this->newCars->findAll();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment