Re: serialize datatype for MDB2

From: Date: Mon, 29 May 2006 11:32:27 +0000
Subject: Re: serialize datatype for MDB2
References: 1 2 3 4  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-42662@lists.php.net to get a copy of this message
On 5/29/06, Lukas Smith <lsmith@php.net> wrote:
Lukas Smith wrote: Alan Knowles wrote:
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.
That does sound like magic that would come back to bite you later... -> accidentally passing an array to quote, would result in some very hard to track down bugs... - where as normally you could dedice a bug from a php error or seeing 'Array' in the database...
Well it would not happen if you explicitly pass a datatype. Not passing in a datatype. And actually my question was more concerned about introducing a new explicit datatype serialize. $array = array('foo'); $mdb2->quote($array); // returns a serialized string because no datatype was giving $mdb2->quote($array, 'text') // would probably give a notice due to an implict array to string cast done by php $mdb2->quote($array, 'serialize') // returns a serialized string as requested $result = $mdb2->query('SELECT someint, somearray FROM foo', array('integer', 'serialize')); $row = $result->fetchRow() // would return an array with an integer and whatever was serialized into the somearray column So any more opinions? Right now I have a +1, -1 and a -0,5
I think its quite useful, +1 from me. -Hannes

« previous php.pear.dev (#42662) next »