The following code returns 11 bank records:
$dbh = new PDO('sqlite:db_coleta.sqlite3');
$sth = $dbh->prepare('SELECT * FROM ROTA_VIEW WHERE usuario_id = 1 AND 0 = 0');
$sth->execute();
$red = $sth->fetchAll();
var_dump($red);
But the following code, using parameter, does not return any record (which is wrong):
$dbh = new PDO('sqlite:db_coleta.sqlite3');
$sth = $dbh->prepare('SELECT * FROM ROTA_VIEW WHERE usuario_id = ? AND 0 = 0');
$sth->execute(array(1));
$red = $sth->fetchAll();
var_dump($red);
I would like to know what I am doing wrong, as I am following examples of the php documentation, everything is the same, except for my problem. I can not understand why this does not work, as it is the same as the following example (taken from link ):
/* Execute a prepared statement by passing an array of values */
$sth = $dbh->prepare('SELECT name, colour, calories FROM fruit WHERE calories < ? AND colour = ?');
$sth->execute(array(150, 'red'));
$red = $sth->fetchAll();
$sth->execute(array(175, 'yellow'));
$yellow = $sth->fetchAll();