First - my code works and no problem with that, but it is not completely safe. I don't know how to bind my query. I know a bout bindParam / bindValue but i don't have any idea how to use those in my case...
My query consists of part and the parts depends of AJAX post:
if(!empty($_POST['manufacturers']))
$manufacturers = $_POST['manufacturers'];
else
$manufacturers = null;
if(!empty($_POST['processors']))
$processors = $_POST['processors'];
else
$processors = null;
if($manufacturers != null)
$manufacturers = ' AND manufacturer.slug IN('.$manufacturers.')';
if($processors != null)
$processors = ' AND processors.slug IN('.$processors.')';
And complete query will be:
$query = "bla bla my query";
$query = $query.$processors.$manufacturers;
Example query is:
SELECT manufacturer.name AS ManufName,
model.model_name AS ModelName,
processors.name ProcName,
laptops.resolution,
inches.name,
graphic_card.name GraphName,
laptops.memory_type,
laptops.memory_size,
laptops.ram,
laptops.price,
laptops.image_path
FROM manufacturer, model, processors, inches, graphic_card, laptops
WHERE manufacturer.id = Laptops.manufacturer_id
AND model.id = Laptops.model_id
AND inches.id = Laptops.inches_id
AND processors.id = Laptops.processor_id
AND graphic_card.id = Laptops.graphic_card_id
AND manufacturer.slug
IN('Dell','Lenovo')
AND processors.slug
IN('Intel_core_i5','Intel_core_i7')
And from post i get in this case: 'Dell','Lenovo' and secondly i get:
'Intel_core_i5','Intel_core_i7'
Query changes by every checkbox change from user interface...
So if user checks only checkbo from manufacturers then the query will not be the same if query checks checkboxes from both - manufacturers and processors...
I need to prevent things like this:
$.post('ajaxCallback.php', {manufacturers: 'sleep(15)'});
How to bind this query or how to make this correctly safe?
I appreciate any help and advice!
Thanks a lot!