I'm getting an error when running a PDO MySQL query and can't work out why
If I do the following
    $sql = 'SELECT * FROM ' . $table;
    if ($where !== false)
        $sql .= ' WHERE ' . implode(' AND ', $where);
    $sql .= ' LIMIT 0, 1';
    $variables = array('index');
    $this->DBH->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
    $statement = $this->DBH->prepare($sql);
    $statement->execute($variables);
    $statement->setFetchMode(PDO::FETCH_ASSOC);
    $rows = $statement->fetch()
It works fine, and I get the expected result. But if I change
    $sql .= ' LIMIT 0, 1';
    $variables = array('index');
To
    $sql .= ' LIMIT ?, ?';
    $variables = array('index', 0, 1);
$rows returns an empty array and I the following warning;
Warning: PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''0', '1'' at line 1 in file.php on line 96("$statement->execute($variables);"
The outputted $sql and $variables are:
SELECT * FROM ma_pages WHERE url = ? LIMIT ?, ?
Array ( [0] => index [1] => 0 [2] => 1 )
 
     
    