Download CD Content
The purpose of this chapter is to explain the use of middleware for reading and writing ordinary files. It also will cover uploading files in PHP.
Before there were database management systems (DBMSs), designers and developers of computer applications made use of files. A file is a collection of information used by computer programs. Files come in different types, indicated by the extensions. You are probably familiar with word processing files, image files, and spreadsheet files. For the score-keeping application shown in this chapter, the file is a set of records, with each record containing a name and a score. The other application explained in this chapter is the uploading of image files that illustrate products. Similar code could be used for files of any type.
Files can be the appropriate choice for an application if the organization of data is simple or, strangely enough, very complex. The score-keeping application fits the criteria of being a simple application. It does not require multiple tables with fields in one table pointing to records in another, and the potential size of the list is small. If the structure of the data is complex in a way that cannot be represented by tables and relationships, then you might be better off using files. For example, an application in which records contain arbitrary pointers to other records might be best implemented using files as opposed to databases.
A benefit of using files over databases is that they do not require the purchase or installation of software. An aspect of using files that is both positive and negative is that you can design any structure you want. This is a positive feature because there are no constraints on how you solve the challenges of your application. However, it is negative because there are no standards. In general, files are designed to work with a single program or small set of programs. Sharing and re-use are limited. Typically, databases are used with multiple applications done by different people and teams within an organization. New applications arise that make use of existing databases.