Chapter 5. Working with Data Stored in Files: When a database just isn’t enough

image with no caption

Don’t believe the hype...about databases, that is. Sure, they work wonders for storing all kinds of data involving text, but what about binary data? You know, stuff like JPEG images and PDF documents. Does it really make sense to store all those pictures of your rare guitar pick collection in a database table? Usually not. That kind of data is typically stored in files, and we’ll leave it in files. But it’s entirely possible to have your virtual cake and eat it too—this chapter reveals that you can use files and databases together to build PHP applications that are awash in binary data.

Virtual guitarists like to compete

Apparently creating art for art’s sake isn’t always enough because players of the hot new game Guitar Wars are quite enamored with competitive virtual guitar playing. So much so that they regularly post their high scores at the Guitar Wars web site, which you are now in charge of maintaining. Problem is, there isn’t currently a good way to verify the scores.

image with no caption

Text can’t be trusted

Right now players just post up their high scores purely as text, and there have been lots of disputes over whose scores are valid and whose aren’t. There’s only one way to put an end to all this bickering and crown ...

Get Head First PHP & MySQL now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.