Page is a not externally linkable
- WebmasterWorld
-- New To Web Development
---- Using text files to store data with PHP Templates


rocknbil - 6:21 pm on Apr 6, 2010 (gmt 0)


Welcome aboard moonroot, it's absolutely possible and is often referred to as a "flat text database." That alone may lead to resources and even (old!) scripts that do this. I have heard via posts along the years that this site, in fact, functions on plain text files.

Instead of field names, you have to create your own row sets and delimiters, for example, using pipes,

field1|field2|field3

. You have to do all the grunt work that mySQL does for you though. Manage carriage returns, split lines into arrays, searching the data becomes tedious and more difficult to implement, deleting/updating rows is more work, insuring proper file locking to avoid corruption, you need to write your own functions to generate "auto_increment" numbers and manage relational data, there are a whole list of challenges.

Another "tricky" one, in my example above, the end or a row of data is determined by the newline/carriage return. You have to implement a way to manage any newlines that may exist within the data for both storing and extracting so that it doesn't "end" the row mid-stream.

The two biggest downsides are that the data becomes exceptionally large in comparison to database engines and constantly opening and closing large text files can be hard on a server's hard disk. This many not be as true today as it was in the 90's, but it's still an issue.


Thread source:: http://www.webmasterworld.com/new_web_development/4110767.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com