I have a problem with a query:
I have a table with "sections" and another table with a Many to Many of SectionCountryException where only I have the values of the countries do not want to appear.
Let me explain: I have many sections and I want some sections are not available in some countries.
Now I have this dql in a Section Table:
$dql = $this->createQuery('se')
->leftJoin('se.SectionCountryExceptions sce')
->whereNotIn('sce.value',$countryCode)
->orderBy....
but I know that's not right, but not how to do it ....
thanks
I answered myself ...
$dql = $this->createQuery('se') ->andWhereNotIn('se.id', $this->getExceptionsArray());
and the function:
private function getExceptionsArray() { $countryCode = sfConfig::get('app_default_country_code'); $sectionCountryExceptions = Doctrine::getTable('SectionCountryException')->findByValue($countryCode); $exceptions = array(); foreach ($sectionCountryExceptions as $exception) { $exceptions[] = $exception->getSection()->getId(); } return $exceptions; }