Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Usnadněte si soužití s Doctrine

Usnadněte si soužití s Doctrine

Filip Procházka

October 27, 2013
Tweet

More Decks by Filip Procházka

Other Decks in Technology

Transcript

  1. Proč Kdyby? - Doctrine má spoustu skvělých vlastností - Doctrine

    má spoustu otravných vlastností - Kdyby je plug&play (convention over configuration), tedy konfigurace na pár řádků a hned můžete pracovat
  2. Entita use Doctrine\ORM\Mapping as ORM; /** @ORM\Entity() */ class Article

    extends \Kdyby\Doctrine\Entities\IdentifiedEntity { /** @ORM\Column(type="string") */ protected $title; }
  3. BaseEntity? Ta je přece fuj! class Article extends BaseEntity {

    private $one; protected $two; public $three; }
  4. Ne, repository nestačí... $article = new Article(); $article->title = "The

    Tigger Movie"; $articles->save($article); $article = $articles->find(1); echo $article->title; // "The Tigger Movie"
  5. Repozitář umí hezky nabobtnat class ArticlesDao extends EntityDao { function

    findByTitle($title); function findByStepmothersBrothersEyeColor(); function findBy...(); }
  6. Hlavně žádné další dědění! class ArticlesDao extends EntityDao { function

    findByTitle($title); function findByStepmothersBrothersEyeColor(); function findBy...(); }
  7. ResultSet $dql = $articles->createQuery("SELECT a FROM Articles a"); $articles =

    new Kdyby\Doctrine\ResultSet($dql); $articles->applyPaginator($this['vp']->paginator);