0

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

0

1 Answer 1

0

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;
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.