How to apply PDO method in ORDER BY and LIMIT clauses? DO NOT use bindValue.
How to get Select to Order and Limit via $_Get(s)?
I don't want to use bindValue command, what's the best way to do this?
//-- Exemple return $_GET -- //
$getOrder = 'ASC';
$getLimit = 5;
$orderColun = 'id';
//---------------------- //
$order = $getOrder == 'ASC' ? 'ORDER BY ? ASC' : 'ORDER BY ? DESC' ;
$limit = $getLimit != ''? intval($getLimit) : 0;
$sql = "SELECT * FROM test $order LIMIT ?";
$stmt = $PDO->prepare($sql);
$stmt->execute([$orderColun, $limit]);
$return = $stmt->fetchAll(PDO::FETCH_ASSOC);