Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Oct 2002
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    A good format for storing small databases (<100 records) in text files?

    I'm looking to use a text file to store a small database (>100 entries most likely) for a calendar. It would be web-editable through a PHP script. I have access to a MySQL database but do not wish to take the time to learn SQL and would rather store all information in a text file (I don't want to be roped in to having to host with a MySQL provider).

    My current idea would be a database with one record per event, something with these fields:

    date(DD.MM.YYYY format, easily splittable by the periods)
    event_name
    event_summary
    event_location
    event_author (for keeping track of who adds each new event)

    I was looking into a tab-delimited-type file, but as I would most likely use the PHP functions file() and then a regex split by tab, this wouldn't work: the event_summary field could easily have new paragraphs in it, which would involve some sort of replacement character to keep line endings and entry records correct.

    Does anyone have any suggestions on a good file format? Or should I just replace new paragraphs with some sort of text string like "\p\" and stick with tab-delimited files? Thanks!

    Jeff Walden
    Last edited by Waldo; 08-03-2003 at 07:02 PM.

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    If your going to be having paragraphs, it seems to be easier and much more efficent to use MySQL. Especially if you are going to be having more than a 100 entries. If you are concerned about learning SQL, don't, it is incredibly easy. Plus PHP and MySQL work easily together.

    Check out: http://www.w3schools.com/sql/

    If your using PHP, most hosts will have MySQL support.
    OracleGuy

  • #3
    New Coder
    Join Date
    Oct 2002
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You know, the more I think about it, the more I think I will use MySQL. I should have remembered being forced to host with an SQL provider (often at extra cost) won't be a problem if I have to switch hosting services - the new PHP (5.0.0 Beta) will have a database system (SQLite) built-in, so I won't need to worry about having to host with someone with a DB program, I'll just need one running a newer version of PHP (or I can ask if they could install the newer version).

    Thanks for the help!

    Jeff

  • #4
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    XML

    why don't you store it without database , into XML files

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <events>
    <event id="1">
    <date />
    <name />
    <summary />
    <location />
    <author />
    </event>
    </events>

  • #5
    New Coder
    Join Date
    Oct 2002
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I did consider XML, but looking through the manual pages for it in PHP, it looked a little harder to do. Or at least to understand - the MySQL stuff, after a quick SQL tutorial, is pretty straightforward, I think.

    Anyways, it's moot now, as I'm in the middle of coding using the MySQL database I have access to. I've run into the occasional problem, but they've been nothing I can't work my way through eventually.

    Jeff


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •