Exemple #1
0
 function busca_por_categorias($ids, $limit = 0)
 {
     $produtos = array();
     $ids = $ids == '' ? 0 : $ids;
     // Abre a tabela
     $c = new JCRUD('jos_edesktop_produtos_categorias_rel');
     $where = "WHERE idcategoria IN ({$ids})";
     $where = $limit ? "{$where} ORDER BY RAND() LIMIT {$limit}" : $where;
     if ($this->paginacao) {
         $this->paginacao = $c->paginacao($where, $this->paginacao);
         $where = "{$where} LIMIT {$this->paginacao->limit}";
     }
     $pp = $c->busca($where);
     foreach ($pp as $p) {
         if (!isset($produtos[$p->idproduto])) {
             $produtos[$p->idproduto] = $this->busca_por_id($p->idproduto, true);
         }
     }
     return $produtos;
 }