RE: [PHP-DB] PHP + SQLite - Issues with update
Had already tried that without any success. What bugs me is that if I error the script out rather than exit it cleanly the token value shows up in the DB. It's causing me to wonder if it's some streams issue. Even if it was, I have no idea how to fix it. Thanks, Prashant. > -Original Message- > From: n.a.mor...@brighton.ac.uk [mailto:n.a.mor...@brighton.ac.uk] > Sent: Friday, October 21, 2011 2:33 AM > To: Prashant Prabhudesai (pprabhud); php-db@lists.php.net > Subject: RE: [PHP-DB] PHP + SQLite - Issues with update > > Try using the query: > > $db->query("update SERVER set Token = '$intoken' where IPAddress ='192.168.1.100'"); > > You are trying to update all rows with $intoken, where the column Token is unique. > > Regards, > Neil Morgan > > -Original Message- > From: Prashant Prabhudesai [mailto:pprab...@cisco.com] > Sent: 21 October 2011 04:04 > To: php-db@lists.php.net > Subject: [PHP-DB] PHP + SQLite - Issues with update > > Hello, > > > I am running into some issues trying to update a column in a table in a > SQLite database using PHP on Windows and was hoping could get some help on > this mailer. > > > Here is the create and insert statement - > > > CREATE TABLE SERVER ( > IPAddress varchar(100) not null unique primary key, > Token varchar(100) unique > ); > > > INSERT INTO SERVER (IPAddress, Token) VALUES > ('192.168.1.100', ''); > > > I am trying to update the Token field using the following code - > > > [snip] > > > $db = new SQLiteDatabase('db/reg.s3db'); > > > $intoken = uniqid(); > > > $db->query("update SERVER set Token = '$intoken'"); > > > $res = $db->query("select * from SERVER"); > > > $row = $res->fecth(); > > > $outtoken = $row['Token']; > > > echo $outtoken; > > > [snip] > > > After the script exits successfully I inspect the value in the Token column > and its empty. But the echo statement in the snippet above prints the proper > value. > > > Interestingly, if I error out the script with a syntax error or some such > after the update but before it exits, the value shows up in the Token > column. > > > Any idea what is happening here and I need to do here. Seems like there is > some sort of flush that needs to happen which happens only if the script > errors out. > > > Any help is appreciated. > > > Thanks, > Prashant. > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > ___ > This email has been scanned by MessageLabs' Email Security > System on behalf of the University of Brighton. > For more information see http://www.brighton.ac.uk/is/spam/ > ___ > > ___ > This email has been scanned by MessageLabs' Email Security > System on behalf of the University of Brighton. > For more information see http://www.brighton.ac.uk/is/spam/ > ___ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] SELECT
On Fri, Oct 21, 2011 at 2:09 AM, Ford, Mike wrote: >> -Original Message- >> From: tamouse mailing lists [mailto:tamouse.li...@gmail.com] >> Sent: 20 October 2011 21:37 >> >> On Tue, Oct 18, 2011 at 5:36 AM, Ford, Mike >> wrote: >> >> -Original Message- >> >> From: Ron Piggott [mailto:ron.pigg...@actsministries.org] >> >> Sent: 17 October 2011 18:38 >> >> >> >> What I am storing in the table is the start month # (1 to 12) and >> >> day # (1 to 31) and then the finishing month # (1 to 12) and the >> >> finishing day # (1 to 31) >> >> >> > >> > This is a little bit of a tricky one, as you have to consider both >> > start_month and end_month as special cases - so you need a three- >> part >> > conditional, for the start month, the end month, and the months in >> > between. Something like this: >> > >> > SELECT * FROM `introduction_messages` >> > WHERE (month>`start_month` AND month<`end_month`) >> > OR (month=`start_month AND day>=`start_day`) >> > OR (month=`end_month` AND day<=`end_day`); >> >> This still suffers from the problem in Jim's offer -- wrap of year >> and >> wrap of month > > Look again. Month wrap *is* handled by the specific tests for start_month > and end_month. Hmm -- yes, you are right -- it does handle the month wrap problem okay. > As to year-wrap, Ron's original post said: > >> >> ... The reason I didn’t use ‘DATE’ is because the same message >> >> will be displayed year after year, depending on the date range. > > so I didn't bother about year-wrap, assuming he would include a range > with start_date of 1/1 and another with end_date of 31/12. So you are saying it can be easily worked around if there is a particular case that is supposed to wrap over the end of the year and simply include the item twice: one starting on Jan 1 and the other one ending on Dec 31. (I'm not sure if that's what you meant above.) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] PHP + SQLite - Issues with update
Try using the query: $db->query("update SERVER set Token = '$intoken' where IPAddress ='192.168.1.100'"); You are trying to update all rows with $intoken, where the column Token is unique. Regards, Neil Morgan -Original Message- From: Prashant Prabhudesai [mailto:pprab...@cisco.com] Sent: 21 October 2011 04:04 To: php-db@lists.php.net Subject: [PHP-DB] PHP + SQLite - Issues with update Hello, I am running into some issues trying to update a column in a table in a SQLite database using PHP on Windows and was hoping could get some help on this mailer. Here is the create and insert statement - CREATE TABLE SERVER ( IPAddress varchar(100) not null unique primary key, Token varchar(100) unique ); INSERT INTO SERVER (IPAddress, Token) VALUES ('192.168.1.100', ''); I am trying to update the Token field using the following code - [snip] $db = new SQLiteDatabase('db/reg.s3db'); $intoken = uniqid(); $db->query("update SERVER set Token = '$intoken'"); $res = $db->query("select * from SERVER"); $row = $res->fecth(); $outtoken = $row['Token']; echo $outtoken; [snip] After the script exits successfully I inspect the value in the Token column and its empty. But the echo statement in the snippet above prints the proper value. Interestingly, if I error out the script with a syntax error or some such after the update but before it exits, the value shows up in the Token column. Any idea what is happening here and I need to do here. Seems like there is some sort of flush that needs to happen which happens only if the script errors out. Any help is appreciated. Thanks, Prashant. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ___ This email has been scanned by MessageLabs' Email Security System on behalf of the University of Brighton. For more information see http://www.brighton.ac.uk/is/spam/ ___ ___ This email has been scanned by MessageLabs' Email Security System on behalf of the University of Brighton. For more information see http://www.brighton.ac.uk/is/spam/ ___ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] SELECT
> -Original Message- > From: tamouse mailing lists [mailto:tamouse.li...@gmail.com] > Sent: 20 October 2011 21:37 > > On Tue, Oct 18, 2011 at 5:36 AM, Ford, Mike > wrote: > >> -Original Message- > >> From: Ron Piggott [mailto:ron.pigg...@actsministries.org] > >> Sent: 17 October 2011 18:38 > >> > >> What I am storing in the table is the start month # (1 to 12) and > >> day # (1 to 31) and then the finishing month # (1 to 12) and the > >> finishing day # (1 to 31) > >> > > > > This is a little bit of a tricky one, as you have to consider both > > start_month and end_month as special cases - so you need a three- > part > > conditional, for the start month, the end month, and the months in > > between. Something like this: > > > > SELECT * FROM `introduction_messages` > > WHERE (month>`start_month` AND month<`end_month`) > > OR (month=`start_month AND day>=`start_day`) > > OR (month=`end_month` AND day<=`end_day`); > > This still suffers from the problem in Jim's offer -- wrap of year > and > wrap of month Look again. Month wrap *is* handled by the specific tests for start_month and end_month. As to year-wrap, Ron's original post said: > >> ... The reason I didn’t use ‘DATE’ is because the same message > >> will be displayed year after year, depending on the date range. so I didn't bother about year-wrap, assuming he would include a range with start_date of 1/1 and another with end_date of 31/12. Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Portland PD507, City Campus, Leeds Metropolitan University, Portland Way, LEEDS, LS1 3HE, United Kingdom E: m.f...@leedsmet.ac.uk T: +44 113 812 4730 But in the case of years actually mattering then, yes, the above would not work To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm