Re: [PHP] File read and sort question

2003-10-06 Thread Burhan Khalid
Susan Ator wrote:

I have no control over

1) file naming
2) file inclusion in the directory
3) file removal from the directory
This is all being handled through another program written in C.
Hrmm what can you do to the files? If this is a linux system, you can 
write a shell script that will do this sort of thing for you, and spit 
the contents out in another directory. Kinda overheadish too, but 
atleast its something different than "database, database, database" ... 
which to be frank, is what I would have said also.

You can create a small script that will quite simply ... do what your 
php script does, but at an interval. You can then take the delay out of 
the the php script, and just run a cron job that repeats the script.

Something tells me a that PERL or even some fancy shell scripting 
trickery would be faster than doing it from php, but I couldn't give you 
a factual calculation of execution times.

Just the thoughts of someone that obviously is lacking in sleep.

--
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] File read and sort question

2003-10-06 Thread Marek Kilimajer
Susan Ator wrote:
I have no control over

1) file naming
2) file inclusion in the directory
3) file removal from the directory
This is all being handled through another program written in C.

So far I have been able to put the relevant info from each file into the
database then display with a simple order by.
Now, I'm attempting to get the correct flow for checking if the file is in
the database but not in the directory so I can delete it from the database.
Trial and error.
Susan
You have 2 possibilities:
- empty the daabase before (or after) each run
- create an index on RELEASE_DATE and RELEASE_TIME and use REPLACE, but 
RELEASE_DATE and RELEASE_TIME must be unique

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


RE: [PHP] File read and sort question

2003-10-06 Thread Susan Ator
I have no control over

1) file naming
2) file inclusion in the directory
3) file removal from the directory

This is all being handled through another program written in C.

So far I have been able to put the relevant info from each file into the
database then display with a simple order by.

Now, I'm attempting to get the correct flow for checking if the file is in
the database but not in the directory so I can delete it from the database.
Trial and error.

Susan

-Original Message-
From: Brad Pauly [mailto:[EMAIL PROTECTED]
Sent: Monday, October 06, 2003 1:06 PM
To: PHP-General
Subject: Re: [PHP] File read and sort question


Susan Ator wrote:

> The problem with using a database is the files within the directory are
> changing on, sometimes, a minute by minute basis. I think reading them
into
> the database then deleting them when they are deleted from the directory
> would be a huge amount of overhead. No?
> 
> Something else which I did not make clear in my previous post; when the
> files are removed from the directory I no longer want them displaying in
my
> web page.

[snip]

> On Mon, 2003-10-06 at 12:10, Susan Ator wrote:
> 
>>I have a directory with an ever-changing number of files. Some will be
>>removed and others added on a continuing basis.
>>
>>The files are ascii with the following layout:
>>
>> Name
>> Subject line
>> mm/dd/
>> hh:mm
>>
>>I can easily get a list of files and pull the necessary information. I

Would it be possible to take advantage of the way the files are named? 
If you included the RELEASE_DATE and RELEASE_TIME in the name of the 
file it would save you the step of reading the files. Just getting the 
contents of the directory should provide all the information. Of course 
you would still need to put that in an array and sort it.

- Brad

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

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



Re: [PHP] File read and sort question

2003-10-06 Thread Brad Pauly
Susan Ator wrote:

The problem with using a database is the files within the directory are
changing on, sometimes, a minute by minute basis. I think reading them into
the database then deleting them when they are deleted from the directory
would be a huge amount of overhead. No?
Something else which I did not make clear in my previous post; when the
files are removed from the directory I no longer want them displaying in my
web page.
[snip]

On Mon, 2003-10-06 at 12:10, Susan Ator wrote:

I have a directory with an ever-changing number of files. Some will be
removed and others added on a continuing basis.
The files are ascii with the following layout:

 Name
 Subject line
 mm/dd/
 hh:mm
I can easily get a list of files and pull the necessary information. I
Would it be possible to take advantage of the way the files are named? 
If you included the RELEASE_DATE and RELEASE_TIME in the name of the 
file it would save you the step of reading the files. Just getting the 
contents of the directory should provide all the information. Of course 
you would still need to put that in an array and sort it.

- Brad

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


Re: [PHP] File read and sort question

2003-10-06 Thread Chris Sherwood
Susan

It appears that you will want to use a database. and update it when the
files are removed. (possibly provide a page to do uploading, modifications
and deletions with .. this way you can automate the db)

other than that you will have to recreate everything each time you process
or display the file list.
and dont read the file into the db unless your gonna do the modifications
there
just store a reference link in the db that way your overhead stays small.

Chris


> The problem with using a database is the files within the directory are
> changing on, sometimes, a minute by minute basis. I think reading them
into
> the database then deleting them when they are deleted from the directory
> would be a huge amount of overhead. No?
>
> Something else which I did not make clear in my previous post; when the
> files are removed from the directory I no longer want them displaying in
my
> web page.
>
> Susan

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



RE: [PHP] File read and sort question

2003-10-06 Thread Robert Cummings
On Mon, 2003-10-06 at 12:36, Susan Ator wrote:
> The problem with using a database is the files within the directory are
> changing on, sometimes, a minute by minute basis. I think reading them into
> the database then deleting them when they are deleted from the directory
> would be a huge amount of overhead. No?

Not if they are changing on a minute by minute basis. Most of your
queries will be selects.

> Something else which I did not make clear in my previous post; when the
> files are removed from the directory I no longer want them displaying in my
> web page.

Double delete, from filesystem and from database. You pretty much have 3
choices that I can think of here:

  1. use a database which is suited to your task
  2. Use the filesystem but load the list everytime and apply ksort
 (you already said you don't want to do this).
  3. Use the filesystem, sort the entries, and cache the sorted result.
 (this is very database like).

Cheers,
Rob.

> 
> Susan
> 
> -Original Message-
> From: Robert Cummings [mailto:[EMAIL PROTECTED]
> Sent: Monday, October 06, 2003 12:18 PM
> To: Susan Ator
> Cc: PHP-General
> Subject: Re: [PHP] File read and sort question
> 
> 
> On Mon, 2003-10-06 at 12:10, Susan Ator wrote:
> > I have a directory with an ever-changing number of files. Some will be
> > removed and others added on a continuing basis.
> > 
> > The files are ascii with the following layout:
> > 
> >  Name
> >  Subject line
> >  mm/dd/
> >  hh:mm
> > 
> > I can easily get a list of files and pull the necessary information. I
> need,
> > however to be able to sort by RELEASE_DATE *and* RELEASE_TIME
> > 
> > Philosophically, what is the best way to handle this? I'm hesitant to pull
> > all the information into an array and use ksort since there are, on
> average,
> > ~1000 messages in this directory which need to be processed.
> 
> Smells like a job for a database :)  Otherwise you'll need to either
> read all the data in, or create another file heirarchy with the
> appropriate redundancy to retrieve in sorted order, which incidentally
> probably loads all the file names then sorts. Really it's a database,
> database, database issue *grin*.
> 
> Cheers,
> Rob.
> -- 
> ..
> | InterJinn Application Framework - http://www.interjinn.com |
> ::
> | An application and templating framework for PHP. Boasting  |
> | a powerful, scalable system for accessing system services  |
> | such as forms, properties, sessions, and caches. InterJinn |
> | also provides an extremely flexible architecture for   |
> | creating re-usable components quickly and easily.  |
> `'
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



RE: [PHP] File read and sort question

2003-10-06 Thread Susan Ator
The problem with using a database is the files within the directory are
changing on, sometimes, a minute by minute basis. I think reading them into
the database then deleting them when they are deleted from the directory
would be a huge amount of overhead. No?

Something else which I did not make clear in my previous post; when the
files are removed from the directory I no longer want them displaying in my
web page.

Susan

-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED]
Sent: Monday, October 06, 2003 12:18 PM
To: Susan Ator
Cc: PHP-General
Subject: Re: [PHP] File read and sort question


On Mon, 2003-10-06 at 12:10, Susan Ator wrote:
> I have a directory with an ever-changing number of files. Some will be
> removed and others added on a continuing basis.
> 
> The files are ascii with the following layout:
> 
>  Name
>  Subject line
>  mm/dd/
>  hh:mm
> 
> I can easily get a list of files and pull the necessary information. I
need,
> however to be able to sort by RELEASE_DATE *and* RELEASE_TIME
> 
> Philosophically, what is the best way to handle this? I'm hesitant to pull
> all the information into an array and use ksort since there are, on
average,
> ~1000 messages in this directory which need to be processed.

Smells like a job for a database :)  Otherwise you'll need to either
read all the data in, or create another file heirarchy with the
appropriate redundancy to retrieve in sorted order, which incidentally
probably loads all the file names then sorts. Really it's a database,
database, database issue *grin*.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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

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



Re: [PHP] File read and sort question

2003-10-06 Thread Robert Cummings
On Mon, 2003-10-06 at 12:10, Susan Ator wrote:
> I have a directory with an ever-changing number of files. Some will be
> removed and others added on a continuing basis.
> 
> The files are ascii with the following layout:
> 
>  Name
>  Subject line
>  mm/dd/
>  hh:mm
> 
> I can easily get a list of files and pull the necessary information. I need,
> however to be able to sort by RELEASE_DATE *and* RELEASE_TIME
> 
> Philosophically, what is the best way to handle this? I'm hesitant to pull
> all the information into an array and use ksort since there are, on average,
> ~1000 messages in this directory which need to be processed.

Smells like a job for a database :)  Otherwise you'll need to either
read all the data in, or create another file heirarchy with the
appropriate redundancy to retrieve in sorted order, which incidentally
probably loads all the file names then sorts. Really it's a database,
database, database issue *grin*.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



[PHP] File read and sort question

2003-10-06 Thread Susan Ator
I have a directory with an ever-changing number of files. Some will be
removed and others added on a continuing basis.

The files are ascii with the following layout:

 Name
 Subject line
 mm/dd/
 hh:mm

I can easily get a list of files and pull the necessary information. I need,
however to be able to sort by RELEASE_DATE *and* RELEASE_TIME

Philosophically, what is the best way to handle this? I'm hesitant to pull
all the information into an array and use ksort since there are, on average,
~1000 messages in this directory which need to be processed.

Susan

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