由于某种原因,这段代码不起作用,我不知道为什么:
$action = array('id', 'lurl', 'account');
$request = 3;
$stm = $pdo->prepare("SELECT ? FROM (SELECT * FROM urls ORDER BY id DESC LIMIT ?) sub ORDER BY id ASC");
$stm->bindValue(1, implode(',', $action));
$stm->bindValue(2, $request, PDO::PARAM_INT);
$stm->execute();
$data = $stm->fetchAll();
它所做的只是返回以下数组:
Array ( [0] => Array ( [id,lurl,account] => id,lurl,account ) [1] => Array ( [id,lurl,account] => id,lurl,account ) [2] => Array ( [id,lurl,account] => id,lurl,account ) )
但是当我像这样在查询中手动输入数据时:
SELECT id,lurl,account FROM (SELECT * FROM urls ORDER BY id DESC LIMIT 3);
它做它应该做的事情。有人知道为什么吗?