Created
March 23, 2011 10:16
-
-
Save mathiasverraes/882898 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** @Entity */ | |
class Bug | |
{ | |
/** @Column(type="integer") */ | |
private $id; | |
/** @Column(length=50) */ | |
private $status; | |
//... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// $em instanceof Doctrine\ORM\EntityManager | |
$fixedbugs = $em->getRepository('Bug') | |
->findBy(array('status' => 'fixed')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$fixedbugs = $em | |
->createQuery("SELECT b FROM Bug b WHERE b.status = 'fixed'") | |
->getResult(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @Entity(repositoryClass="BugRepository") | |
*/ | |
class Bug | |
{ /* ... */ } | |
class BugRepository extends EntityRepository | |
{ | |
public function findAllFixedBugs() | |
{ | |
return $this->_em | |
->createQuery("SELECT b FROM Bug b WHERE b.status = 'fixed'") | |
->getResult(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$fixedbugs = $em->getRepository('Bug')->findAllFixedBugs(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment