* and then John Nichel declared....
> John Holmes wrote:
> >You can't just remove part of a file like you remove part of a string. 
> >You'll need to read (eventually) the entire file and only write back 
> >what you want to keep.
> >
> >Now, you said this could be a very large file, so you don't want to read 
> >the whole thing into memory. That's smart, so maybe using a swap file 
> >would be handy? Read from file1, if it's a URL you want to keep, then 
> >write it to file2. rinse, lather, repeat and at the end rename file2 to 
> >file1. This way you're only reading one line at a time into memory.
> >
> 
> Is keeping this info in a db an option?

Not a good one, no. I've tried to figure a schema for it but it's been a
long time since i did db work ;-)

Speed is key here, it's an app that uses the Google API to fetch
relevant urls, then uses cURL to fetch the pages, and if the user wants,
to POST to that page. A DB would be okay i think but filesystem calls
are just faster aren't they?

Where I fail on the DB schema is getting my head around the relationship
between the data, here's roughly what i need to do if anyone is curious
or might prod me in the right direction...

Each user (must have an id,name clearly) can fetch as many urls as they
wish, those urls get written to the db, then as each url is fetched from
the db it is dealt with with php and deleted from the db.

What if a user gets cut off from the script and a whole bunch of
unwanted urls are in the db though? 

Should the db go like this?

db_urls
url_id | user_id | project_id | url

db_user
user_id | name | whatever

db_project
project_id | user_id

Wow, now i've written it down it seems clearer ;) you guys reckon that's
the right kind of schema (based on what you know from the above..)?

Thanks John Holmes, that's seems pretty neat but i may have been
mistaken, i did a test with 5000 urls (shouldnt get much more than that
at any one time) and the memory usage wasnt so bad at all...

-- 
Nick W

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

Reply via email to