Change search request for autocomplete with multiple value

This commit is contained in:
Michael RICOIS 2012-10-27 13:27:36 +00:00
parent eae1265e37
commit 0dd41a8c11

View File

@ -57,12 +57,14 @@ class FieldsController extends Zend_Controller_Action
$where = '';
$i = 0;
foreach ($queries as $item) {
if (strlen($item)>2) {
$where = 'LIKE "%'.strtolower($item).'%"';
}
$i++;
if (count($queries) < $i){
$where.= ' OR ';
if (empty($where)) {
$op = 'LIKE ';
} elseif ($i < count($queries)) {
$op = ' OR ';
}
if (strlen($item)>2) {
$where.= $op.'"%'.strtolower($item).'%"';
}
}
$sql->where("LOWER(lib) ".$where);
@ -97,12 +99,14 @@ class FieldsController extends Zend_Controller_Action
$where = '';
$i = 0;
foreach ($queries as $item) {
if (strlen($item)>2) {
$where.= 'LIKE "%'.strtolower($item).'%"';
}
$i++;
if (count($queries) < $i){
$where.= ' OR ';
if (empty($where)) {
$op = 'LIKE ';
} else {
$op = ' OR ';
}
if (strlen($item)>2) {
$where.= $op.'"%'.strtolower($item).'%"';
}
}
$sql->where("LOWER(NC) ".$where);
@ -122,12 +126,14 @@ class FieldsController extends Zend_Controller_Action
$where = '';
$i = 0;
foreach ($queries as $item) {
if (strlen($item)>2) {
$where.= 'LIKE "%'.strtolower($item).'%"';
}
$i++;
if (count($queries) < $i){
$where.= ' OR ';
if (empty($where)) {
$op = 'LIKE ';
} else {
$op = ' OR ';
}
if (strlen($item)>2) {
$where.= $op.'"%'.strtolower($item).'%"';
}
}
$sql->where("LOWER(libdep) ".$where);
@ -147,12 +153,14 @@ class FieldsController extends Zend_Controller_Action
$where = '';
$i = 0;
foreach ($queries as $item) {
if (strlen($item)>2) {
$where.= 'LIKE "%'.strtolower($item).'%"';
}
$i++;
if (count($queries) < $i){
$where.= ' OR ';
if (empty($where)) {
$op = 'LIKE ';
} else {
$op = ' OR ';
}
if (strlen($item)>2) {
$where.= $op.'"%'.strtolower($item).'%"';
}
}
$sql->where("LOWER(Commune) ".$where);
@ -191,13 +199,15 @@ class FieldsController extends Zend_Controller_Action
$where = '';
$i = 0;
foreach ($queries as $item) {
if (strlen($item)>3) {
$where = 'LIKE "%'.$item.'%"';
}
$i++;
if (count($queries) < $i){
$where.= ' OR ';
}
if (empty($where)) {
$op = 'LIKE ';
} else {
$op = ' OR ';
}
if (strlen($item)>3) {
$where.= $op.'"%'.strtolower($item).'%"';
}
}
$sql->where('LOWER(fjLibelle) '.$where);
}