PHP | Problem - SQL
$filter = "Price < " . $maxprice . " AND Price > " . $minprice . " AND isActive = '" . $isActive . "'" . " AND AmenityID = '" . $AmenityID . "'";
Debug::show($filter);
$sort = 'Created ASC';
$join = 'LEFT JOIN `Apartment_Amenities` ON `ApartmentID` = `Apartment`.ID';
$limit = $_REQUEST['start'].",10";
return DataObject::get('Apartment', $filter, $sort, $join, $limit);
28/02/2012 8:16pm
PHP | Solution - Anonymous
// for testing, you should get an array of ids from the url, or you get it as string right away and remove the implode, but make sure you escape it!
$AmenityIDs = array(1,2,3,1337);
$AmenityIDs = implode(',', $AmenityIDs);
$filter = "Price < $maxprice AND Price > $minprice AND isActive = $isActive AND AmenityID IN ($AmenityIDs)";
$sort = 'Created ASC';
$join = 'LEFT JOIN `Apartment_Amenities` ON `ApartmentID` = `Apartment`.ID';
$limit = $_REQUEST['start'].",10";
return DataObject::get('Apartment', $filter, $sort, $join, $limit);
28/02/2012 8:13pm
PHP | Solution - Anonymous
if(isset($_GET['AmenityID'])) {
$AmenityID = Convert::raw2sql($_GET['AmenityID']);
}
else {
$AmenityID = '1';
}