Welcome Guest, Not a member yet? Register   Sign In
How I can diminish the size of this search?
#1

[eluser]andregufc[/eluser]
Quote://CALCULATE TOTAL ROWS
if (!empty($Imo_Cart_Folha)){$this->db->where('(Imo_Cart_Folha = '.$Imo_Cart_Folha.')');}
if (!empty($Imo_Cart_Par)){$this->db->where('(Imo_Cart_Par = '.$Imo_Cart_Par.')');}
if (!empty($Imo_Cart_Quadra)){$this->db->where('(Imo_Cart_Quadra = '.$Imo_Cart_Quadra.')');}
if (!empty($Imo_Cart_Lote)){$this->db->where('(Imo_Cart_Lote = '.$Imo_Cart_Lote.')');}
if (!empty($Imo_Cart_Bloco)){$this->db->where('(Imo_Cart_Bloco = '.$Imo_Cart_Bloco.')');}
if (!empty($Imo_Cart_Economia)){$this->db->where('(Imo_Cart_Economia = '.$Imo_Cart_Economia.')');}

$totalrows = $this->orm->recordsCount('Imovel');
$_SESSION['linhas'] = $totalrows;

//GET DATA
if (!empty($Imo_Cart_Folha)){$this->db->where('(Imo_Cart_Folha = '.$Imo_Cart_Folha.')');}
if (!empty($Imo_Cart_Par)){$this->db->where('(Imo_Cart_Par = '.$Imo_Cart_Par.')');}
if (!empty($Imo_Cart_Quadra)){$this->db->where('(Imo_Cart_Quadra = '.$Imo_Cart_Quadra.')');}
if (!empty($Imo_Cart_Lote)){$this->db->where('(Imo_Cart_Lote = '.$Imo_Cart_Lote.')');}
if (!empty($Imo_Cart_Bloco)){$this->db->where('(Imo_Cart_Bloco = '.$Imo_Cart_Bloco.')');}
if (!empty($Imo_Cart_Economia)){$this->db->where('(Imo_Cart_Economia = '.$Imo_Cart_Economia.')');}

$this->db->orderby($item, $ordem);
$query = $this->db->get('Imovel', $num, $offset);
return($query);

Thx!
#2

[eluser]ELRafael[/eluser]
how you get this vars? ($Imo_Cart_Bloco, etc..)

maybe you can do a dynamic where, but i need to know how you get this vars...

PS: (vc é brasileiro?)
#3

[eluser]andregufc[/eluser]
opa so sim =) finalmente axei alguem aki q fla pt.. entaum, eu pego ela através do $_POST['campo']... mas oq eu realmente queria saber eh se eh realmente necessário repetir a pesquisa, uma vez para contar o numero de registros encontrados e outra para pegar os dados.

eu dei uma pesquisada aki no forum e axei algumas coisas, mas nada resolveu..

vlw!
#4

[eluser]andregufc[/eluser]
obs.: essas variaveis q eu mostrei, são apenas uma parte da consulta.

A tabela possui mais de 500 mil registros e a consulta possui umas 30 cláusulas where e like além das que eu mostrei, por isso a consulta está um pouco lenta...
tradução do google =P

obs.: these variaveis q I showed, I am only one part of the consultation.

The table possesss more than 500 a thousand registers and the consultation possesss 30 clauses (where and like) beyond that I showed, therefore the consultation is slow…
#5

[eluser]ELRafael[/eluser]
Let'me understand one thing... You'll make one query with 30 where/like conditions? For sure your query'll be slow!!!

Try to think if your logic is correct!

if you have this vars by post, you can do this (try a foreach)
Code:
$this->db->where($key_from_post, $value_from_post);

To count the regs, use
Code:
$this->db->count_all('table_name');


-------------------
A galera aqui provavelmente vai reclamar se tiver post em portugues, vamo bater uma aposta ? tá ligado como é gringo né :coolsmirk:

Já a sua tradução by google ficou hilária velho... mas enfim!

Tipo, se vc tiver 30 consultas por where/like, vc vai fritar mesmo a aplicação cara! tenta rever essa regra de negócios ae... Mas acho que dá pra por a procura dinamica, igual tá os blocos de código acima.

Me manda um PM, ai a gente conversa fora do forum mesmo!!!

Abraços




Theme © iAndrew 2016 - Forum software by © MyBB