![]() |
Web Conference 2005Writing PHP for ITS/ASET Web servicesSaving Data on the Server |
![]() |
| <- Back - Email Submission Form | | | Up | | | Saving Data in Files - Next -> |
In addition to sending user-supplied data over email, there are times when you wish to keep the data on the server. This not only allows you to tidy up your inbox and not stress the email system with too much data, but allows you to reuse the data on the site. Interactive sites, registration forms, bulletin boards and many other applications can benefit from such a flow of data.
Types of server-side data storage include:
| name | description | ||
|---|---|---|---|
| Flat text files | Files you access via fopen(), fread(), fwrite(), fscanf(), file_get_contents(), file_put_contents(), etc, in a format you build yourself. | Yes | Yes |
| SQLite database files | Files you access via sqlite_open(), sqlite_query(), sqlite_fetch_array(), etc; an SQL92 compliant method of accessing files like databases. | Yes | Yes |
| MySQL | A relational database server that you may access via mysql_connect(), mysql_query(), mysql_fetch_array(), etc. The most popular database used with PHP. | Yes | No |
| PostgreSQL | A relational database server that you may access via pg_connect(), pg_query(), pg_fetch_array(), etc. | Yes | No |
| DB2 | A relational database server that you may access via odbc_connect(), odbc_exec(), odbc_fetch_array(), etc or db2_connect(), db2_exec(), db2_fetch_array(), etc. | Not yet | Hopefully soon |
Accessing files directly, as described in the "Flat text files" section above, is the old-fashioned method of storing data on the server. Back in the heyday of Perl and CGI this was the most popular method used. Since PHP grew up with databases being the norm, most applications available for PHP require use of a database, such as MySQL. Both Perl and PHP may access both plain files and databases. This lesson describes activities on doing both from PHP.
Unfortunately, there is no fully-featured database service provided
for php.scripts.psu.edu at the time of this tutorial. Our exercises
will utilize SQLite, a database-like way of accessing files. It is our
aim to find and appropriate a database server for use by
php.scripts.psu.edu in the not-too-distant future.
There is a database service available today that provides DB2 databases for dynamic Web sites. Read about the comparison to the Database Service for Research and Instructional Use.
Tips for using a remote database
| <- Back - Email Submission Form | | | Up | | | Saving Data in Files - Next -> |
|
If you have any questions, feel free to ask me. Content by: Jeff D'Angelo <jcd@psu.edu> © 2005 Last update on: Mon Jun 13, 2005, 12:54:54 AM |
|