Skip to content

Instantly share code, notes, and snippets.

@jenkoian
Last active December 11, 2015 22:09
Show Gist options
  • Save jenkoian/4667994 to your computer and use it in GitHub Desktop.
Save jenkoian/4667994 to your computer and use it in GitHub Desktop.
Simple doctrine find last modified thing
<?php
/**
* @return null|\DateTime
*/
public function findLastModifiedThing()
{
$query = $this->createQueryBuilder('t')
->select('t.updated_at')
->orderBy('t.updated_at', 'desc')
->setMaxResults(1);
$result = $query->getQuery()->getOneOrNullResult();
return null == $result ? null : $result['updated_at'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment