This is driving me nuts. I just started using it today as an alternative to ADODB as PDO looks and feels more natural for me and what Im doing.
Anywho, I have created a DB connection, that works perfect. I can do my first select statement:
$sql = 'SELECT * FROM pc';
foreach($dbh->query($sql) as $a_row){
But my real issue is getting my variables to populate...I am using the following:
$sth = $dbh->prepare('UPDATE stats SET
name = :name,
downloaded = :downloaded,
duedate = :duedate,
progress = :progress
WHERE id = 1');
$sth->bindValue(':name', $PARSE->name, PDO::PARAM_STR);
$sth->bindValue(':downloaded', $PARSE->downloaded, PDO::PARAM_STR);
$sth->bindValue(':duedate', $PARSE->duedate, PDO::PARAM_STR);
$sth->bindValue(':progress', $PARSE->progress, PDO::PARAM_INT);
$passed = $sth->execute();
if($passed){
echo "passed";
} else {
echo "failed: ". $sth->errorInfo();
echo var_dump($sth);
}
I set id to 1 manually for testing purposes. $PARSE is an instance of another class but it is just returning data...which var_dump shows is ok. The error I get from having echo "failed: ". $sth->errorInfo(); echo var_dump($sth); in there is this:
failed: Arrayobject(PDOStatement)#4 (1) { ["queryString"]=> string(176) "UPDATE stats SET name = :name, downloaded = :downloaded, duedate = :duedate, progress = :progress WHERE wuid = 1" }
This is driving me nuts as I have tried everything in the php manual...the different methods and such. If I put my variables right in the SQL statement (e.g. $PARSE->name) the true values show up but I get a warning stating that nothing has been bound (bind).