serialize datatype for MDB2
| From: | Lukas Smith | Date: | Tue, 23 May 2006 20:51:09 +0000 |
| Subject: | serialize datatype for MDB2 | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-42581@lists.php.net to get a copy of this message | ||
Hi,
In my own framework webbuilder2 I have extended the datatype module of MDB2 to feature a "serialize" datatype. Using this I can simply pass in an array into any parameter and then it is automatically serialized when writing and deserialized when reading.
I have refrained from adding abstract datatypes like these uptil now. Recently I added a call to serialize if someone passes an array to the quote() method without specifying an explict datatype to use. So I have sort of added 1/4 of the abstract "serialize" datatype.
You can see the modified Common.php of the datatype module here:
http://svn.oss.backendmedia.com/library/MDB2/Driver/Datatype/Common.phps
So for the most part its just using the code for the "text" datatype with a call to serialize/unserialize as needed.
Here is some sample code using "serialize" to read data from the database:
http://svn.oss.backendmedia.com/library/StageLoader/SQL.phps
And here is some code that uses "serialize" for data writes:
http://svn.oss.backendmedia.com/modules/user_preferences/user_preferences.phps
It works and its useful. The question is just if I am polluting MDB2 with a very high level feature and thereby opening the flood gates too all sorts of high level stuff.
So lets have a brief discussion if there is interest and then a quick poll.
regards,
Lukas