Created
September 1, 2011 09:49
-
-
Save codecowboy/1185843 to your computer and use it in GitHub Desktop.
Motivation repository
This file contains 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 | |
namespace Gymloop\CoreBundle\Entity; | |
use Doctrine\ORM\EntityRepository; | |
/** | |
* MotivationRepository | |
* | |
* This class was generated by the Doctrine ORM. Add your own custom | |
* repository methods below. | |
*/ | |
class MotivationRepository extends EntityRepository | |
{ | |
public function findOneOrderedByDate($user) | |
{ | |
$query = $this->getEntityManager()->createQuery(' | |
SELECT m FROM GymloopCoreBundle:Motivation m | |
WHERE m.user = :user | |
ORDER BY m.date DESC'); | |
$query->setParameter('user',$user); | |
$query->setFirstResult(0); | |
$query->setMaxResults(1); | |
//@TODO if there is not result recorded for the user, return sth which indicates this | |
return $query->getResult(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment