Control result of database
This commit is contained in:
parent
e249753b24
commit
fe37b17fac
@ -92,11 +92,13 @@ class FieldsController extends Zend_Controller_Action
|
||||
$sql->where("LOWER(NC) ".$where);
|
||||
}
|
||||
$result = $table->fetchAll($sql);
|
||||
foreach ($result as $item) {
|
||||
$output[] = array(
|
||||
'label' => $item->NCCENR . ' (Région)',
|
||||
'value' => 'R'.$item->REGION
|
||||
);
|
||||
if (count($result)>0) {
|
||||
foreach ($result as $item) {
|
||||
$output[] = array(
|
||||
'label' => $item->NCCENR . ' (Région)',
|
||||
'value' => 'R'.$item->REGION
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//Département
|
||||
@ -117,11 +119,13 @@ class FieldsController extends Zend_Controller_Action
|
||||
$sql->where("LOWER(libdep) ".$where);
|
||||
}
|
||||
$result = $table->fetchAll($sql);
|
||||
foreach ($result as $item) {
|
||||
$output[] = array(
|
||||
'label' => $item->libdep . ' (Département)',
|
||||
'value' => 'D'.$item->numdep
|
||||
);
|
||||
if (count($result)>0) {
|
||||
foreach ($result as $item) {
|
||||
$output[] = array(
|
||||
'label' => $item->libdep . ' (Département)',
|
||||
'value' => 'D'.$item->numdep
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//Ville
|
||||
@ -142,24 +146,28 @@ class FieldsController extends Zend_Controller_Action
|
||||
$sql->where("LOWER(Commune) ".$where);
|
||||
}
|
||||
$result = $table->fetchAll($sql);
|
||||
foreach ($result as $item) {
|
||||
$output[] = array(
|
||||
'label' => $item->Commune . ', '. $item->Codepos .' (Ville)',
|
||||
'value' => 'C'.$item->INSEE
|
||||
);
|
||||
if (count($result)>0) {
|
||||
foreach ($result as $item) {
|
||||
$output[] = array(
|
||||
'label' => $item->Commune . ', '. $item->Codepos .' (Ville)',
|
||||
'value' => 'C'.$item->INSEE
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
} elseif ( preg_match('/[0-9]{1,5}/', $q) ) {
|
||||
|
||||
//Code Postal
|
||||
$table = new Application_Model_CodePostaux();
|
||||
$sql = $table->select()->where('Codepos LIKE "'.$q.'%"');
|
||||
$sql = $table->select()->where('Codepos LIKE "'.$q.'%"')->limit(1);
|
||||
$result = $table->fetchAll($sql);
|
||||
foreach ($result as $item) {
|
||||
$output[] = array(
|
||||
'label' => $item->Codepos . ' ( Code postal )',
|
||||
'value' => $item->Codepos
|
||||
);
|
||||
if (count($result)>0) {
|
||||
foreach ($result as $item) {
|
||||
$output[] = array(
|
||||
'label' => $item->Codepos . ' ( Code postal )',
|
||||
'value' => $item->Codepos
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user