Beginner's PHP Tutorial - Data storage|
Data Management with php
By Red Squirrel
This article is a continuation of my last php article, which turned out to be quite popular, but it only covers the basics. This article will continue on and go more into details along with base mysql information. It will cover data management with file databases and as well as mysql databases. Both are good methods of storing data, such as submitted forms, or even the posts, topics, settings etc of an entire message board!
This article script in particular uses both a mysql database and file database. The mysql part takes care of counting hits, pages, the title, categories and as well as the folder the article data is in, the file database part takes the files page1.htm page2.htm etc from the folder specified in the mysql database, and displays the html, which also points to the folder when there's pictures and such. This saves us from creating the site layout in every article. If you take the google ads to the left for example, it is not inserted into every article, just one php file that takes care of loading the database and article according to the parameters (what is after the .php? part in the url)
Depending on the application, file databases can be better then mysql, and in other applications, mysql can be better. In this article, when I refer to file database I simply mean an ordinary file on the server, or a group of files, that act to store data.
Mysql databases are better for when it comes to mass data management, such as a forum, because it is known to be faster and less of a load on the server. It can handle more. File databases, on the other hand, are for smaller applications where not lot of processing is involved, because it's much easier to program a script to use files, then it is to program a script to use mysql, to a certain degree. A script such as a counter, is better off with a file database. This entire site has a specialized logging system which is incorporated into most pages, and is run on a file database, you can't really tell much that it's there because it does not process much data, so a mysql database could actually end up being more of a load and more complex to program given the operations needed in this system. On the next page, we'll make a simple script that will act as a guest book system.
||Pages: