I have a quick question, I am hoping it is an easy answer but if I wanted a query like the following:
SELECT * FROM items ORDER BY date ASC
Is there anyway to replace the order by information with prepared statement attributes? would either of the following work?
SELECT * FROM items ORDER BY :column :order
OR
SELECT * FROM items ORDER BY ? ?
and then use bindParam or bindValue to assign those values? If I can't do that I know I can use conditionals to have multiple queries set and then use the correct query based on if the conditional is correct or not for example:
$value = filter_input(INPUT_POST, "value", FILITER_SANITIZE_STRING);
if($value = "date1"){
$query = "SELECT * FROM items ORDER BY date ASC";
}elseif($value = "date2"){
$query = "SELECT * FROM items ORDER BY date DESC";
}
I would like to use the top if at all possible as it would be much easier. Is it possible to use prepared statements that way?