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
https://forums.phpfreaks.com/topic/219970-flat-file-database/
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
https://forums.phpfreaks.com/topic/219970-flat-file-database/#findComment-1140246
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
https://forums.phpfreaks.com/topic/219970-flat-file-database/#findComment-1140264
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
https://forums.phpfreaks.com/topic/219970-flat-file-database/#findComment-1140276
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.