When I build the query
$search=
$search=if($beds){$search= $search.'array("beds","=","'.$beds.'"),';}
$search=if($baths){$search= $search.'array("beds","=","'.$baths.'"),';}
$search when expanded look like this:
array("beds","=","2"),
array("baths","=","2"),
This works:
$listingsList = $listings ->
GetList(array(
array("beds","=","2"),
array("baths","=","2"),
)
,"", true, "$offset,$limit"
);
but when I use $search I get the error: "You have an error in your SQL
syntax"
$listingsList = $listings ->
GetList(array(
$search
)
,"", true, "$offset,$limit"
);
Any ideas?
Thanks,
Frank
yes, i think i see your problem. because $search contains not only data
but php directives (in your case "array"), try this:
$listingsList = $listings ->
GetList(array(
{$search}
)
,"", true, "$offset,$limit"
);
or try
eval ("\$listingsList = \$listings ->
GetList(array(".
$search."
)
,\"\", true, \"\$offset,\$limit\"
);";
let me know if this helps
Joel
Your suggestions words. I had to play with it a bit and here is the
resulting code. I am runing the query twice, the first time without the
limit to obtain a count for pagination. I hope this will be helpful to
others.
eval ('
$count= count(
$listingsList = $listings ->
GetList(array(
'.$search.'
)
));
'); //end eval
$page=ceil($count/$limit); //# of pages
eval ('
$listingsList = $listings ->
GetList(array(
'.$search.'
)
,"", true, "$offset, $limit"
);
'); //end eval
Its amazing what can be done with POG. Thank you for making it
available and also for your time,
Frank