<?php

namespace OfficeBrain\Bundle\CategoryBundle\Entity;

use Doctrine\ORM\EntityRepository;

/**
 * CountryCategoryIgnoreRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class CountryCategoryIgnoreRepository extends EntityRepository
{
	public function getIgnoreData()
	{
		$query=$this->createQueryBuilder('cci')
		->select('cci.id as id','cci.catMapId as cat_map_id','cci.countryId as country_id');
		$ignoreData = $query->getQuery()->getResult();
		return $ignoreData;
	}
	public function addInCategoryIgnore($countryId,$catMapId,$pmsId)
	{
		$em = $this->getEntityManager();
		$categoryIgnoreObj= new CountryCategoryIgnore();
		$categoryIgnoreObj->setCountryId($countryId);
		$categoryIgnoreObj->setCatMapId($catMapId);
		$categoryIgnoreObj->setPmsId($pmsId);
		$em->persist($categoryIgnoreObj);
		$em->flush();
		return $categoryIgnoreObj;
	}
	public function removeFromCategoryIgnore($countryId,$catMapId)
	{
		$queryBuilder = $this->createQueryBuilder('cci');
		$queryBuilder->delete('OfficeBrainCategoryBundle:CountryCategoryIgnore', 'cci');
		$queryBuilder->where('cci.catMapId = :catMapId AND cci.countryId = :countryId')
		->setParameter('catMapId', $catMapId)
		->setParameter('countryId', $countryId);
		return $queryBuilder->getQuery()->execute();
		
	}
}
