Home arrow PHP arrow Working with MySQL and Sessions to Serialize Objects in PHP

Working with MySQL and Sessions to Serialize Objects in PHP

If you're interested in learning how to combine objects, sessions and MySQL, this is the article that you’ve been waiting for. It's the final part of the series “Serializing objects in PHP.” In three parts, this series goes through the fundamentals of serializing objects in PHP applications, and explores some advanced topics with regard to this subject, including the use of the magic “__sleep()” and “__wakeup()” functions, and the manipulation of serialized objects inside of MySQL tables.

TABLE OF CONTENTS:
  1. Working with MySQL and Sessions to Serialize Objects in PHP
  2. The basics of automated object serialization: using objects and sessions
  3. Combining objects and sessions: defining a session handling class
  4. Another implementation of object serialization: saving objects to MySQL tables
  5. The complete list of classes for the example
By: Alejandro Gervasio
Rating: starstarstarstarstar / 16
June 20, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

If you’ve been reading the previous tutorials, then you’ve hopefully learned the basics of how to serialize/unserialize objects in PHP, as well as how to use the combination of “__sleep()” and “__wakeup()” functions to create objects that are capable of maintaining their state across different web page requests. As you’ll probably recall, these types of objects are called persisting objects, and in general terms, are constructed without the need to use the PHP built-in session handling mechanism.

Aside from the practical implementation of serialization for building persisting objects, it should be noted that there’s plenty of room to use serialized objects in Web applications, either as part of more advanced programming approaches, or in order to achieve something as simple as storing objects in text files and cookies. Once you’ve mastered the concepts behind object serialization, you can go ahead and develop several applications (an object caching system, to cite an illustrative example), which use serialization for achieving some basic tasks.

Provided that you’ve already grasped the key concepts about object serialization, in addition to implementing some advanced features, such as the ones I mentioned right at the beginning of this article, in this final installment of the series, I’ll show you some examples of how to work with objects and sessions. I'll also show you how to use MySQL tables to keep your objects safe and healthy.

So, are you interested in learning how to combine objects, sessions and MySQL? Let’s start exploring this powerful combination.



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
   

PHP ARTICLES

- 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...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap

Dev Shed Tutorial Topics: