Re: [Jason] Search problem
Hi,
with this code:
$where = "";
if (is_array(@$_REQUEST['oblast_grad'])) {
$where .= "(";
foreach ($_REQUEST['oblast_grad'] as $oblast_grad) {
$where .= " oblast_grad LIKE '%\t".mysql_escape($oblast_grad)."\t%' OR";
}
$where = rtrim($where, "OR") . ")";
}
if (is_array(@$_REQUEST['vid_na_imota'])) {
if ($where) { $where .= " AND "; }
$where .= "(";
foreach ($_REQUEST['vid_na_imota'] as $vid_na_imota) {
$where .= " vid_na_imota LIKE '%\t".mysql_escape($vid_na_imota)."\t%' OR";
}
$where = rtrim($where, "OR") .")";
}
list($imotiRecords, $imotiMetaData) = getRecords(array(
'tableName' => 'imoti',
'orderBy' => mysql_escape(@$_REQUEST['orderBy']),
'perPage' => '2',
'where' => $where,
)); $where = "";
if (is_array(@$_REQUEST['oblast_grad'])) {
foreach ($_REQUEST['oblast_grad'] as $oblast_grad) {
$where .= " oblast_grad LIKE '%\t".mysql_escape($oblast_grad)."\t%' OR";
}
$where = rtrim($where, "OR");
}
if (is_array(@$_REQUEST['vid_na_imota'])) {
foreach ($_REQUEST['vid_na_imota'] as $vid_na_imota) {
$where .= " vid_na_imota LIKE '%\t".mysql_escape($vid_na_imota)."\t%' OR";
}
$where = rtrim($where, "OR");
}
list($imotiRecords, $imotiMetaData) = getRecords(array(
'tableName' => 'imoti',
'orderBy' => mysql_escape(@$_REQUEST['orderBy']),
'perPage' => '2',
'where' => $where,
'debugSql' => true,
));
the output:
SELECT SQL_CALC_FOUND_ROWS `imoti`.* FROM `cms_imoti` as `imoti` WHERE ( oblast_grad LIKE '% Troshevo %' OR oblast_grad LIKE '% Mladost %' vid_na_imota LIKE '% 1-room %' OR vid_na_imota LIKE '% 2-rooms %' ) LIMIT 2
MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'vid_na_imota LIKE '% 1-room %' OR vid_na_imota LIKE '% 2-rooms %' ) LIMIT 2' at line 3
Cheers