Check if there are active products in this brand, if not, show brand

Asked

Viewed 36 times

-2

I have two tables in my bank, adm_marca and adm_produto, at the moment, is showing in my view all brands, regardless if there are active products or not, I need to show only brands that do not have active products. How to do this check?

My view:

  <?php foreach ($marcas as $marca) { ?>
                            <li><a href="<?php echo base_url("marca/" . $marca->getSlug()); ?>"><?php echo $marca->getNome(); ?></a></li>
                        <?php } ?>

Marca_model:

  public function marcas(){
   return $this->doctrine->em->getRepository("Entity\AdmMarca")->findBy(array('status'=> 1));   
}  

1 answer

0

  • The problem is that I would have to make a Ner Join, the only relationship I have between the tables is the product table that contains the brand ID. But if I create a method that takes the product table to validate, I can’t bring the brands themselves.

  • Then use not(), I modified the answer there!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.