Re: serialize datatype for MDB2
| From: | Matthias Nothhaft | Date: | Wed, 24 May 2006 10:38:59 +0000 |
| Subject: | Re: serialize datatype for MDB2 | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-42592@lists.php.net to get a copy of this message | ||
Lukas Smith wrote:
> 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ɉ
> t4!bš:¶EQçà3
>
>
> 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.
maybe not a good idea, but what about making it pluggable:
registerDatatypeConversion($type, $cb_in, $cb_out) or similar..
ok.. forget it ;-)