Re: serialize datatype for MDB2
| From: | Matthias Nothhaft | Date: | Wed, 24 May 2006 10:22:55 +0000 |
| Subject: | Re: serialize datatype for MDB2 | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-42590@lists.php.net to get a copy of this message | ||
Lukas Smith wrote:
>> Lukas Smith wrote:
>
> $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
My expierience is that it is a good practise to always set the
datatype.. Thus, there should be no strange behaviour.
I'm +1 for that datatype :-)
Note: This also allowes to easily store objects in your database.
Regards,
Matthias