Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Todo;
- use Nette;
- /**
- * Provádí operace nad databázovou tabulkou.
- */
- abstract class Repository extends Nette\Object
- {
- /** @var Nette\Database\Connection */
- protected $connection;
- public function __construct(Nette\Database\Connection $db)
- {
- $this->connection = $db;
- }
- /**
- * Vrací objekt reprezentující databázovou tabulku.
- * @return Nette\Database\Table\Selection
- */
- protected function getTable()
- {
- // název tabulky odvodíme z názvu třídy
- preg_match('#(\w+)Repository$#', get_class($this), $m);
- return $this->connection->table(lcfirst($m[1]));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment