Entity/DocumentTagRepository.php
author ymh <ymh.work@gmail.com>
Sun, 16 Oct 2011 14:50:48 +0200
changeset 2 13f43f53d0ba
child 5 45378793512a
permissions -rw-r--r--
first implementation

<?php

namespace IRI\Bundle\WikiTagBundle\Entity;

use Doctrine\ORM\EntityRepository;

/**
 * DocumentTagRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class DocumentTagRepository extends EntityRepository
{
    /**
    *  Find ordered tags by document id
    */
    public function findOrderedTagsForDoc($doc_id)
    {
        return $this->getEntityManager()
        ->createQuery("SELECT doctag FROM WikiTagBundle:DocumentTag doctag WHERE doctag.document=:doc_id ORDER BY doctag.tagOrder ASC")
        ->setParameter("doc_id", $doc_id)
        ->getResult();
    }
    
    /**
     *  Gets the max order of all tags for one document
     */
    public function getMaxOrder($doc_id)
    {
        return $this->getEntityManager()
        ->createQuery("SELECT MAX(doctag.tagOrder) FROM WikiTagBundle:DocumentTag doctag  WHERE doctag.document= :doc_id")
        ->setParameter("doc_id", $doc_id)
        ->getResult();
    }
    
}