Sqlite 3 pdo update query problem

Sqlite 3 pdo update query problem

am 20.08.2008 10:08:42 von Amy Gibbs

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

Re: Sqlite 3 pdo update query problem

am 20.08.2008 10:59:13 von Evert Lammerts

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

Re: Sqlite 3 pdo update query problem

am 20.08.2008 11:02:58 von Amy Gibbs

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

Re: Sqlite 3 pdo update query problem

am 20.08.2008 11:11:24 von Evert Lammerts

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

Re: Sqlite 3 pdo update query problem

am 20.08.2008 12:06:49 von Amy Gibbs

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

Re: Sqlite 3 pdo update query problem

am 20.08.2008 12:26:35 von Amy Gibbs

--Apple-Mail-23-402627229
Content-Type: text/plain;
charset=US-ASCII;
format=flowed;
delsp=yes
Content-Transfer-Encoding: 7bit

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


--Apple-Mail-23-402627229--

Re: Sqlite 3 pdo update query problem

am 20.08.2008 12:42:37 von Evert Lammerts

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

Re: Sqlite 3 pdo update query problem

am 20.08.2008 12:44:18 von Amy Gibbs

Thanks for trying,

On 20 Aug 2008, at 11:42, Evert Lammerts 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 > > 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 >> >
>> 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 >> >
>>
>> 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

Re: Sqlite 3 pdo update query problem

am 20.08.2008 12:45:31 von Evert Lammerts

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

Re: Sqlite 3 pdo update query problem

am 20.08.2008 12:50:37 von Amy Gibbs

--Apple-Mail-25-404069067
Content-Type: text/plain;
charset=US-ASCII;
format=flowed;
delsp=yes
Content-Transfer-Encoding: 7bit

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


--Apple-Mail-25-404069067--

Re: Sqlite 3 pdo update query problem

am 20.08.2008 12:59:21 von Evert Lammerts

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

Re: Sqlite 3 pdo update query problem

am 20.08.2008 13:04:18 von Amy Gibbs

--Apple-Mail-26-404890210
Content-Type: text/plain;
charset=US-ASCII;
format=flowed;
delsp=yes
Content-Transfer-Encoding: 7bit

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


--Apple-Mail-26-404890210--

Re: Sqlite 3 pdo update query problem

am 20.08.2008 13:11:21 von Evert Lammerts

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 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/seinv audit.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
> 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
> 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
>
> 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
>
> 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

Re: Sqlite 3 pdo update query problem

am 20.08.2008 13:11:43 von Amy Gibbs

--Apple-Mail-27-405335135
Content-Type: text/plain;
charset=US-ASCII;
format=flowed;
delsp=yes
Content-Transfer-Encoding: 7bit

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

then I got 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

which was a permissions error on the folder,

now i'm timing out and getting nothing,

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


--Apple-Mail-27-405335135--

Re: Sqlite 3 pdo update query problem

am 20.08.2008 13:20:58 von Evert Lammerts

Can you post the code you're using when you get the timeout?

I guess you already tried to do a select only and an update only to
check if it works?

On Wed, Aug 20, 2008 at 1:11 PM, Amy Gibbs 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);
> then I got 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/seinv audit.php on lin
> which was a permissions error on the folder,
> now i'm timing out and getting nothing,
> 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
> 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
> 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
>
> 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
>
> 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

Re: Sqlite 3 pdo update query problem

am 20.08.2008 13:23:03 von Evert Lammerts

Forget my last mail. Good to hear it's solved.

On Wed, Aug 20, 2008 at 1:20 PM, Evert Lammerts
wrote:
> Can you post the code you're using when you get the timeout?
>
> I guess you already tried to do a select only and an update only to
> check if it works?
>
> On Wed, Aug 20, 2008 at 1:11 PM, Amy Gibbs 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);
>> then I got 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/seinv audit.php on lin
>> which was a permissions error on the folder,
>> now i'm timing out and getting nothing,
>> 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
>> 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
>> 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
>>
>> 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
>>
>> 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

Re: Sqlite 3 pdo update query problem

am 20.08.2008 14:40:07 von Neil Smth

At 09:15 20/08/2008, you wrote:

>Message-Id:
>From: Amy Gibbs
>Date: Wed, 20 Aug 2008 09:08:42 +0100
>
>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.


Things I'd try or check presuming the DB file it exists and returns
rows from the SELECT :

(1) Ensure the SQLite DB file is not set to read-only in the
filesystem, which will prevent UPDATE
(2) Echo out the $sql line below on each iteration, to ensure it
contains what you intend, and not unclosed quotes
(3) Set $sesdb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

Step 3 should make your code barf when it can't execute a query and
immediately indicate the problem.
For some reason, PDO seems to default to silent errors at least when
using the SQLite interface

HTH
Cheers - Neil


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



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