Hi,
I'm not very experienced in PHP, and have always used mysql with it,
but now I have a Sqlite database that I want to manipulate and I
thought PHP would be an easy way to do it. It turned out that I need
to use PDO to access a Sqlite V3 database, which is all new to me.
I've managed to connect to my database, and run a select query, but
now I need to run an UPDATE query and it just doesn't seem to take
effect. Here's the code I'm using, I've tried all sorts of
combinations, prepare, execute, query, but when I go back into the db
it hasn't updated the rows.
[code]
$sesdb = new PDO('sqlite:file.sqlite3');
$query="SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE
ZCategory != 14";
$statement= $sesdb->query($query);
$result=$statement->fetchAll();
foreach ($result as $product) {
$prodname=$product[0];
$prodqty = $product[1];
$prodid=$product[2];
$sql = "UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='".$prodid."'";
$sesdb->exec($sql);
}
[/code]
When I re-run the select query, the ZQuantity is still as it was
before. I've tried echoing out the query and running it on the db
directly and that seems fine.
This isn't issuing any error messages either, it's just continuig with
the next code (SELECT query again to check the db contents)
Can anyone help me?
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php