<?php

namespace Market\ZodacoBundle\Entity;

use Doctrine\ORM\EntityRepository;

/**
 * InformationsCategoriesRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class InformationsCategoriesRepository extends EntityRepository
{
    public function _getCatlist() {
        $q = 'SELECT c FROM MarketZodacoBundle:InformationsCategories c WHERE c.active=1 AND c.mid=0 ORDER BY c.sort ASC';
        return $this->getEntityManager()
                        ->createQuery($q)
                        ->getResult();
    }

    /*
     * For Admin
     */

    public function _getAdminCatlist2() {
        $q = 'SELECT c FROM MarketZodacoBundle:InformationsCategories c WHERE c.mid!=0 ORDER BY c.sort ASC';
        return $this->getEntityManager()
                        ->createQuery($q)
                        ->getResult();
    }

    public function _getAdminCatlist() {
        $q = 'SELECT c FROM MarketZodacoBundle:InformationsCategories c WHERE c.mid=0 ORDER BY c.sort ASC';
        return $this->getEntityManager()
                        ->createQuery($q)
                        ->getResult();
    }

    public function _getSubId($id) {
        $q = 'SELECT c.id FROM MarketZodacoBundle:InformationsCategories c WHERE c.mid=' . $id . ' ORDER BY c.sort ASC';
        return $this->getEntityManager()
                        ->createQuery($q)
                        ->getResult();
    }

    public function _getSublist($id) {
        $q = 'SELECT c FROM MarketZodacoBundle:InformationsCategories c WHERE c.mid=' . $id . ' ORDER BY c.sort ASC';
        return $this->getEntityManager()
                        ->createQuery($q)
                        ->getResult();
    }

    public function _getSublistShow($id) {
        $q = 'SELECT c FROM MarketZodacoBundle:InformationsCategories c WHERE c.active=1 AND c.mid=' . $id . ' ORDER BY c.sort ASC';
        return $this->getEntityManager()
                        ->createQuery($q)
                        ->getResult();
    }

    public function _delId($id) {
        $q = 'DELETE FROM MarketZodacoBundle:InformationsCategories c WHERE c.id=' . $id;
        return $this->getEntityManager()
                        ->createQuery($q)
                        ->getResult();
    }
}
