|
Posted by Jerry Stuckle on 07/19/06 11:03
Manish wrote:
> The project I am developing doesn't involves database. I want to parse
> the mailbox file (.mbx) and store the summary in the text file for fast
> retrieval and display of information in the Inbox page.
>
> The sugegsted format are as:
>
> #1
>
> ID [4 bytes]: Subject [100 bytes]: To Address[100 bytes]: From
> Address[100 bytes]...etc...
>
> #2
>
> Instead of preassining fixed size to variable (as actual data may be
> much less or can grew to more), we can store the values continuously,
> seperated by some unique seperator (#|#, *#*, ...)
>
> 1324#|#Hi, How are you#|#me@google.com#|#you@google.com#|# ... and so
> on
>
>
> Which of these will be the efficeint one (as there will be frequent
> insert/delete/update of the individual information, eg. set message as
> read ..., delete message ..., new message ...)
>
> Also please suggest on how to determine the variable size (100 bytes as
> in #1), and assign the size to the variable accordingly and read it
> (differentiate multiple variables) when required.
>
> Thanks.
>
> Manish
>
Personally, I'd use a database. I wouldn't even try a flat file for
this. Too much work trying to keep things straight.
But you asked about the formats. The fixed length fields will have
extra space any time the amount of data is less than that of the amount
reserved. Then you run into the problem of someone who gets very
verbose with their subject line and exceeds the 100 characters. And 4
bytes allows up to 9999 ID's. Is that enough? Or are you going to try
to read/write binary (not easy in PHP)?
The second one is problematical because the user may include your
separator in its Subject: line (or even name/address if you pick the
wrong character).
Two other ways - use CSV format, which is well documented and supported
by PHP and other programs. Or, add a length field at the beginning of
each field, specifying how many characters in the following field.
But I'd still use a database.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|