Home arrow PHP arrow PHP Datastorage Class

PHP Datastorage Class

Many websites use databases for storing data for use by web applications. There are situations in which this is not the best solution, however. For light, moderate, or temporary storage requirements, you might prefer to use flat files, session variables, and cookies. This article will describe how to create a class that handle all of these. It is the first of two parts.

  1. PHP Datastorage Class
  2. Top of the Page
  3. Flat Files
  4. Getting Data In
  5. Getting Data Out
By: Chris Root
Rating: starstarstarstarstar / 10
November 14, 2005

print this article



Web applications need data. Getting data in and out of an application with the minimum amount of code can be a challenge, and it can be rather easy to end up with something that is not portable or reusable in any way.

Many times databases are a natural choice for storing data for use by a web application. If you have ever worked on a site that makes extensive use of a database, however, you likely know the strain it can put on a system. A database isn't always the best solution for light or temporary data storage, so it makes sense to have something else that fits your requirements.

In this article I will guide you through the design of a data storage class that can meet the needs of a long list of web applications requiring light to moderate or temporary storage requirements.

Where Will It All Go?

There are three places we can store data that will be useful to us. These are a flat file, session variables and cookies. The class described here can use all of these. If you were to add some sort of database abstraction class to it, database storage could be used as well.

This class has been used as the core of a number of different applications so far.

A shopping cart.

An email and web page hit counter.

Storage of temporary customer registration information.

A debugger logger for template based pages.

A project management system.

Multi-page form storage.

Data conversion tool.

There are many more potential uses, and once you finish this article I'm hoping you will have some of your own ideas.

>>> More PHP Articles          >>> More By Chris Root

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: