Gentlemen, I have the following function:
// Busca Simples
public function buscando(){
// pesquisar_palavra, idCategoria, idSubCategoria
if($this->input->post('pesquisar_palavra')){
$this->db->like('noticia.titulo', $this->input->post('pesquisar_palavra'));
}
if($this->input->post('idCategoria')){
$this->db->select('noticia.*, categoria.categoria');
$this->db->join('categoria', "categoria.id=noticia.id");
$this->db->where('categoria.id', $this->input->post('idCategoria'));
}
if($this->input->post('idSubCategoria')){
$this->db->where('noticia.id_categoria', $this->input->post('idSubCategoria'));
}
$this->db->where('noticia.ativo', 1);
$this->db->order_by('noticia.data', 'DESC');
$this->db->order_by('noticia.id', 'DESC');
$consulta = $this->db->get('noticia')->result();
echo "<pre>";
print_r($consulta);
echo "</pre>";
die();
}
The return of it is just a record, not 3, as the following database shows:
This is the Search Post criterion.
Array
(
[pesquisar_palavra] =>
[idCategoria] => 1
[idSubCategoria] => 5
)