Re: Sqlite 3 pdo update query problem

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

 



It seems you've figured it out. I think you only need to chmod the DB
directory and you're good to go.

On Wed, Aug 20, 2008 at 1:04 PM, Amy Gibbs <amy@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> OK, I found one problem, the database file was not writeable, I added this
> code to find the error:
> $sesdb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
> However, I now get the following error:
> Warning: PDO::exec() [function.PDO-exec]: SQLSTATE[HY000]: General error: 14
> unable to open database file
> in/home/amy2203/public_html/willowtreecrafts/seweblink/seinvaudit.php on lin
> Sorry to have such a basic problem!
> 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
>
>
>

-- 
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