Re: sqlite if query changes to empty on a loop

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

 




On Thu, May 10, 2007 2:55 pm, chris@xxxxxxxxxxxx wrote:
> Hello,
>
> I have a loop on an sqlite query which checks $domain until the status
> of
> $domain changes and then it deletes $domain.
>
> However when all the $domain items have been deleted I need the script
> to
> stop.. regardless of how many querys the loop
> still has to run. So I want to detect when its empty and then stop.
>
> I have this... which does not work.
>
> <?
> $db = sqlite_open("whois.sqlite");
>
> $x = 0;
> while ($x < 9000) {
>
> $result = sqlite_query($db, "SELECT * FROM whois ORDER BY id");
>
> // if (!$result) {
> if (empty($result)) {
>
> echo "No data";

I dunno for sure what empty() is gonna do with $result, but I suspect
that this message should say "query failed" rather than "no data"

No data returned is not an error, it's just an empty set, which is
very common.

> } else {
>
> while ($row = sqlite_fetch_array($result)) {
>
> $domain = $row['name'];
>
> echo "$domain";

The quotes is kinda silly here...

> $x++;
> usleep(400000);
> }
> }
> }
> sqlite_close($db);
> ?>

You said you were deleting things...?

Where?

What are you actually trying to do?

"delete from whois" springs to mind as a MUCH better way from what you
described, but not what you coded...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux