How to use pdo's prepared statement for order by and limit ?
Posted
by user198729
on Stack Overflow
See other posts from Stack Overflow
or by user198729
Published on 2010-04-21T14:04:31Z
Indexed on
2010/04/21
15:03 UTC
Read the original article
Hit count: 197
$sql = "SELECT * FROM table ORDER BY :sort :dir LIMIT :start, :results";
$stmt = $dbh->prepare($sql);
$stmt->execute(array(
'sort' => $_GET['sort'],
'dir' => $_GET['dir'],
'start' => $_GET['start'],
'results' => $_GET['results'],
)
);
I tried to use prepare
to do the job,but $stmt->fetchAll(PDO::FETCH_ASSOC);
returns nothing.
© Stack Overflow or respective owner