Re: Sqlite 3 pdo update query problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Alright, getting somewhere.

Try this:

$sesdb = new PDO('sqlite:wtc.sqlite3');
if ($sesdb->exec("UPDATE ZITEM SET ZQUANTITY=0 WHERE
ZPRODUCTID='bli-343'") === false) {
echo $sesdb->errorInfo();
}

Don't forget the quotes around the product id (it's a string so you
need them after all)


On Wed, Aug 20, 2008 at 12:50 PM, Amy Gibbs <amy@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> It still doesn't run the update, but the var_dump displays
> bool(false) bool(false)
> $sesdb = new PDO('sqlite:wtc.sqlite3');
> $sql = "UPDATE ZITEM SET ZQUANTITY=0 WHERE ZPRODUCTID=bli-343";
> var_dump($sesdb->exec("UPDATE ZITEM SET ZQUANTITY=0 WHERE
> ZPRODUCTID=bli-343"));
> $sesdb->exec($sql);
> var_dump($sesdb->exec("UPDATE ZITEM SET ZQUANTITY=0 WHERE
> ZPRODUCTID=bli-343"));
> $query="SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=
> 14";
>
>
> On 20 Aug 2008, at 11:45, Evert Lammerts wrote:
>
> What happens if you try the UPDATE before a SELECT?
>
> $sesdb = new PDO('sqlite:file.sqlite3');
> var_dump($sesdb->exec("UPDATE ZITEM SET ZQUANTITY=0 WHERE ZPRODUCTID=1"));
>
> On Wed, Aug 20, 2008 at 12:42 PM, Evert Lammerts
> <evert.lammerts@xxxxxxxxx> wrote:
>
> Sorry, I'm out of options. Hopefully somebody on the list has a little
>
> more experience with PDO.
>
> On Wed, Aug 20, 2008 at 12:26 PM, Amy Gibbs <amy@xxxxxxxxxxxxxxxxxxxxxx>
> wrote:
>
> It's still not working :(
>
> $query="SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=
>
> 14";
>
> $statement= $sesdb->query($query);
>
> $result=$statement->fetchAll();
>
> $statement=null;
>
> 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);
>
> On 20 Aug 2008, at 11:10, Evert Lammerts wrote:
>
> A little time on google told me that if you want to do a write after a
>
> read (or the other way around) you need to free up the query resource
>
> - apparently they hold read / write locks.
>
> so, free up $statement before doing a write:
>
> $sesdb = new PDO('sqlite:file.sqlite3');
>
> $query="SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=
>
> 14";
>
> $statement= $sesdb->query($query);
>
> $result=$statement->fetchAll();
>
> $statement=null;
>
> 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);
>
> }
>
>
> On Wed, Aug 20, 2008 at 11:49 AM, Amy Gibbs <amy@xxxxxxxxxxxxxxxxxxxxxx>
>
> wrote:
>
> No errors reported, but it's not updating the db,
>
> error_reporting(E_ALL);
>
> $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);
>
> }
>
> On 20 Aug 2008, at 10:11, Evert Lammerts wrote:
>
> can you put
>
> error_reporting(E_ALL);
>
> somewhere above the query and check if there's some output?
>
> On Wed, Aug 20, 2008 at 11:02 AM, Amy Gibbs <amy@xxxxxxxxxxxxxxxxxxxxxx>
>
> wrote:
>
> still not working,
>
>
> $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);
>
> }
>
> On 20 Aug 2008, at 09:59, Evert Lammerts wrote:
>
> $sql = "UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='".$prodid."'";
>
> Try to unquote $prodid:
>
> $sql = "UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid}";
>
> Evert
>
> --
>
> PHP Database Mailing List (http://www.php.net/)
>
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
> --
>
> PHP Database Mailing List (http://www.php.net/)
>
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
> --
>
> PHP Database Mailing List (http://www.php.net/)
>
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
>
>
>
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux