Commit 70bcc07099b1f77108d1d4291e98e397d52cfc47
1 parent
4c953573
Exists in
master
by Eriksen: Atualizado método lista() para ordernar pelo campo sigla_uf por padrão
Showing
1 changed file
with
61 additions
and
61 deletions
Show diff stats
ieducar/intranet/include/pessoa/clsUf.inc.php
@@ -154,67 +154,67 @@ class clsUf | @@ -154,67 +154,67 @@ class clsUf | ||
154 | return false; | 154 | return false; |
155 | } | 155 | } |
156 | 156 | ||
157 | - /** | ||
158 | - * Exibe uma lista baseada nos parametros de filtragem passados | ||
159 | - * | ||
160 | - * @return Array | ||
161 | - */ | ||
162 | - function lista( $str_nome=false, $str_geom=false, $int_idpais=false, $int_limite_ini=false, $int_limite_qtd=false, $str_orderBy = false ) | ||
163 | - { | ||
164 | - // verificacoes de filtros a serem usados | ||
165 | - $whereAnd = "WHERE "; | ||
166 | - | ||
167 | - if( is_string( $str_nome ) ) | ||
168 | - { | ||
169 | - $where .= "{$whereAnd}nome LIKE '%$str_nome%'"; | ||
170 | - $whereAnd = " AND "; | ||
171 | - } | ||
172 | - if( is_string( $str_geom ) ) | ||
173 | - { | ||
174 | - $where .= "{$whereAnd}geom LIKE '%$str_geom%'"; | ||
175 | - $whereAnd = " AND "; | ||
176 | - } | ||
177 | - if( is_numeric( $int_idpais ) ) | ||
178 | - { | ||
179 | - $where .= "{$whereAnd}idpais = '$int_idpais'"; | ||
180 | - $whereAnd = " AND "; | ||
181 | - } | ||
182 | - else | ||
183 | - { //brasil | ||
184 | - $idpais = $this->config->app->locale->country; | ||
185 | - $where .= "{$whereAnd}idpais = '$idpais'"; | ||
186 | - $whereAnd = " AND "; | ||
187 | - } | ||
188 | - | ||
189 | - if($str_orderBy) | ||
190 | - { | ||
191 | - $orderBy = "ORDER BY $str_orderBy"; | ||
192 | - } | ||
193 | - | ||
194 | - $limit = ""; | ||
195 | - if( is_numeric( $int_limite_ini ) && is_numeric( $int_limite_qtd ) ) | ||
196 | - { | ||
197 | - $limit = " LIMIT $int_limite_ini,$int_limite_qtd"; | ||
198 | - } | ||
199 | - $db = new clsBanco(); | ||
200 | - $db->Consulta( "SELECT COUNT(0) AS total FROM {$this->schema}.{$this->tabela} $where" ); | ||
201 | - $db->ProximoRegistro(); | ||
202 | - $total = $db->Campo( "total" ); | ||
203 | - $db->Consulta( "SELECT sigla_uf, nome, geom, idpais FROM {$this->schema}.{$this->tabela} $where $orderBy $limit" ); | ||
204 | - $resultado = array(); | ||
205 | - while ( $db->ProximoRegistro() ) | ||
206 | - { | ||
207 | - $tupla = $db->Tupla(); | ||
208 | - $tupla["idpais"] = new clsPais( $tupla["idpais"] ); | ||
209 | - $tupla["total"] = $total; | ||
210 | - $resultado[] = $tupla; | ||
211 | - } | ||
212 | - if( count( $resultado ) ) | ||
213 | - { | ||
214 | - return $resultado; | ||
215 | - } | ||
216 | - return false; | ||
217 | - } | 157 | + /** |
158 | + * Retorna um array com os registros da tabela public.uf | ||
159 | + * @return array | ||
160 | + */ | ||
161 | + public function lista($str_nome = FALSE, $str_geom = FALSE, $int_idpais = FALSE, | ||
162 | + $int_limite_ini = FALSE, $int_limite_qtd = FALSE, $str_orderBy = 'sigla_uf ASC') | ||
163 | + { | ||
164 | + $whereAnd = 'WHERE '; | ||
165 | + | ||
166 | + if (is_string($str_nome)) { | ||
167 | + $where .= "{$whereAnd}nome LIKE '%$str_nome%'"; | ||
168 | + $whereAnd = ' AND '; | ||
169 | + } | ||
170 | + | ||
171 | + if (is_string($str_geom)) { | ||
172 | + $where .= "{$whereAnd}geom LIKE '%$str_geom%'"; | ||
173 | + $whereAnd = ' AND '; | ||
174 | + } | ||
175 | + | ||
176 | + if (is_numeric($int_idpais)) { | ||
177 | + $where .= "{$whereAnd}idpais = '$int_idpais'"; | ||
178 | + $whereAnd = ' AND '; | ||
179 | + } | ||
180 | + else { | ||
181 | + $idpais = $this->config->app->locale->country; | ||
182 | + $where .= "{$whereAnd}idpais = '$idpais'"; | ||
183 | + $whereAnd = ' AND '; | ||
184 | + } | ||
185 | + | ||
186 | + if ($str_orderBy) { | ||
187 | + $orderBy = "ORDER BY $str_orderBy"; | ||
188 | + } | ||
189 | + | ||
190 | + $limit = ''; | ||
191 | + if (is_numeric($int_limite_ini) && is_numeric($int_limite_qtd)) { | ||
192 | + $limit = " LIMIT $int_limite_ini,$int_limite_qtd"; | ||
193 | + } | ||
194 | + | ||
195 | + $db = new clsBanco(); | ||
196 | + $db->Consulta("SELECT COUNT(0) AS total FROM {$this->schema}.{$this->tabela} $where"); | ||
197 | + $db->ProximoRegistro(); | ||
198 | + | ||
199 | + $total = $db->Campo('total'); | ||
200 | + | ||
201 | + $db->Consulta("SELECT sigla_uf, nome, geom, idpais FROM {$this->schema}.{$this->tabela} $where $orderBy $limit"); | ||
202 | + $resultado = array(); | ||
203 | + | ||
204 | + while ($db->ProximoRegistro()) | ||
205 | + { | ||
206 | + $tupla = $db->Tupla(); | ||
207 | + $tupla['idpais'] = new clsPais($tupla['idpais']); | ||
208 | + $tupla['total'] = $total; | ||
209 | + $resultado[] = $tupla; | ||
210 | + } | ||
211 | + | ||
212 | + if (count($resultado)) { | ||
213 | + return $resultado; | ||
214 | + } | ||
215 | + | ||
216 | + return FALSE; | ||
217 | + } | ||
218 | 218 | ||
219 | /** | 219 | /** |
220 | * Retorna um array com os detalhes do objeto | 220 | * Retorna um array com os detalhes do objeto |