PDO 准备语句返回 false

PDO prepared statement returning false

知道为什么会返回 false 吗?

用于调用函数的代码:

$product = new Product;
$allProducts = $product->getProducts(12);

我正在调用的函数:

public function getProducts($limit)
    {
        $values = array($limit);
        $statement = $this->conn->prepare('SELECT * FROM sellify_items ORDER BY id DESC LIMIT ?');
        $statement->execute($values);
        $result = $statement->fetchAll();
        if ($result) {
            return $result;
        }
        return false;
    }

编辑:更新函数

public function getProducts($limit)
{
    $values = array(intval($limit));
    $statement = $this->conn->prepare('SELECT * FROM sellify_items ORDER BY id DESC LIMIT ?');
    $statement->bindValue(0, $limit, PDO::PARAM_INT);
    $statement->execute($values);
    $result = $statement->fetchAll();
    if ($result) {
        return $result;
    }
    return false;
}

试试这个(注意转换为 int):

$statement->bindValue(0, (int) $limit, PDO::PARAM_INT);