Entity/DocumentTagRepository.php
changeset 2 13f43f53d0ba
child 5 45378793512a
equal deleted inserted replaced
1:06a22ff5d58d 2:13f43f53d0ba
       
     1 <?php
       
     2 
       
     3 namespace IRI\Bundle\WikiTagBundle\Entity;
       
     4 
       
     5 use Doctrine\ORM\EntityRepository;
       
     6 
       
     7 /**
       
     8  * DocumentTagRepository
       
     9  *
       
    10  * This class was generated by the Doctrine ORM. Add your own custom
       
    11  * repository methods below.
       
    12  */
       
    13 class DocumentTagRepository extends EntityRepository
       
    14 {
       
    15     /**
       
    16     *  Find ordered tags by document id
       
    17     */
       
    18     public function findOrderedTagsForDoc($doc_id)
       
    19     {
       
    20         return $this->getEntityManager()
       
    21         ->createQuery("SELECT doctag FROM WikiTagBundle:DocumentTag doctag WHERE doctag.document=:doc_id ORDER BY doctag.tagOrder ASC")
       
    22         ->setParameter("doc_id", $doc_id)
       
    23         ->getResult();
       
    24     }
       
    25     
       
    26     /**
       
    27      *  Gets the max order of all tags for one document
       
    28      */
       
    29     public function getMaxOrder($doc_id)
       
    30     {
       
    31         return $this->getEntityManager()
       
    32         ->createQuery("SELECT MAX(doctag.tagOrder) FROM WikiTagBundle:DocumentTag doctag  WHERE doctag.document= :doc_id")
       
    33         ->setParameter("doc_id", $doc_id)
       
    34         ->getResult();
       
    35     }
       
    36     
       
    37 }