Jump to content

Flat File Database


SyntaxPro

Recommended Posts

Hi, I use MySQL for real projects of course... but, I like to challenge myself and I was wondering how people make advance applications with Flat File databases... My questions are...

 

>Display

  >Reading The Flat File Data

  >Sorting it Alphabetically For Display

  >How to create a WHERE clause affect with the data

 

>Storage

  >Adding Records

  >Deleting Records

  >Editing Records

 

I went over a lot of this on my own, but I'm stuck on certain parts because google only has so much on Flat File Databases... also how would u secure a Flat File Database from someone just simply direct linking to it and viewing it?

Link to comment
Share on other sites

Reading: easy, just read the file. The rest depends on how the stuff is stored (eg, in XML, CSV, plain text...)

Sorting: either the file is sorted already or you have to read the entire thing into memory and sort it there.

Where: complicated, depends on how powerful you want it to be - basically, read each data item and apply the conditions.

 

Adding: if the file is sorted, read the whole thing into memory and insert the new stuff where it belongs; otherwise just append to the file.

Deleting: read the whole thing into memory, delete, and write it all back out.

Editing: read the whole thing into memory, edit, and write it all back out.

 

 

a) Flat files themselves are simple; what you're writing is the database management system.

b) No, real database systems are smarter than that. There's not much "read the whole thing into memory" because the "flat files" are better structured. How all that stuff works is beyond the scope of a PHP forum (and even many database forums).

Link to comment
Share on other sites

Google should have quite a sufficient amount of information on using flat file. In regards to your last point, obviously these files aren't going to be as secure as a database. Best bet is to place the files outside of the main directory structure of your website (not in public_html or www) to prevent users from accessing them.

Link to comment
Share on other sites

Thanks for the help! One last question... lets say u have

 

$test[0] = array("Shane","19","Wisconsin");

$test[1] = array("Ricky","18","Wisconsin");

 

i know thats probably not right syntax i was just getting the point out...

 

how would i sort that alphabetically by the first name?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.