1
I would like an improvement help in a Search Query today every Search the user makes in the search field I give an OR in my Where I wonder if you have any better way to do this because I will need to put but 5 search options for the user
A single search for everything according to the image below
// CONFIGURAÇÃO DO FILTRO
if(isset($_POST['filtro_busca'])){
// Recupero os valores
$conteudo['value_busca'] = $this->input->post('filtro_busca' , TRUE);
}
A part of the Controller where I want to put 5 more parameters in this search or 5 more "OR"
$where .= " AND (
nome like '%{$condicao['value_busca']}%'
OR email like '%{$condicao['value_busca']}%'
OR telefone_1 like '%{$condicao['value_busca']}%'
OR rg like '%{$condicao['value_busca']}%'
OR cpf like '%{$condicao['value_busca']}%'
OR codigo like '%{$condicao['value_busca']}%'
) ";
From what I understand you are making the search return values that should not, because by my understanding should not use
Like
in the fieldsTelefone, RG, CPF, CODIGO
, for being whole fields;– Aprendiz
@Apprentice can’t claim they’re whole, I put as myself
VARCHAR
because I prefer that the masks are saved with on the bench. Shaolin, are you using a search field for all these items? Got a little confused.– Diéfani Favareto Piovezan
That’s right @Diéfanifavaretopiovezan a search field for all items actually this code already running a while ago was done by another guy wanted to give an improved leave automated
– Shaolin Fantastic
What I mean, could check what the user typed, if it was a number then only search in certain fields, since the fields are all
VARCHAR
so it would greatly reduce the response time– Aprendiz
You can make a field that has all the strings of the other fields and just search for this big field. You can use a database Rigger to update this search field, or change the field at the time of update and Insert.
– Daniel
Guy talking about autonomy, just do it with one item, you’ll know what size of your bank, if it’s big you’ll run the whole bank to find one person with all these columns
– Matheus Gonzales