Re: [DB] returning typed data when fetching rows
| From: | Michael Wallner | Date: | Fri, 06 Aug 2004 08:43:45 +0000 |
| Subject: | Re: [DB] returning typed data when fetching rows | ||
| References: | 1 | Groups: | php.pear.general php.pear.qa |
| Request: | Send a blank email to pear-general+get-13982@lists.php.net to get a copy of this message | ||
Hi Guillaume Cocatre-Zilgien, you wrote:
> Hello,
>
> I have been writing a custom class for using a PostgreSQL database,
> while looking at the DB classes to see if I could take advantage of them.
>
> Although I plan to use them in the near future, there is at least one
> feature that I find missing from them: I would like to have strongly
> typed data when fetching rows. I expect to get PHP integers, arrays,
> booleans instead of strings ('4', '{"foo","bar",{"this
> is foobar"}}',
> 't'...).
>
> So I have written some methods that:
> 1) collect information about fields and caches them (feature
> available in PEAR classes)
> 2) convert a PHP value into an SQL string (supports PG arrays)
> 3) convert a value returned by the database (string) into a typed value
> (supports PG arrays as well)
>
> I think this should be implemented directly in PHP's extensions (in
> pg_fetch_row(), for instance), but since it isn't, I was wondering if
> such features would be welcome in PEAR's DB classes - not just for
> PostgreSQL, but also the other DB's implementations).
>
> If they are welcome, to which class(es) should they be added? DB_Table
> supports some type casting, but not for fetching rows, and it doesn't
> support arrays. Perhaps DB_pgsql and the likes?
>
> Please let me know what you think.
Have a look at MDB[2]
Regards,
--
Michael - < mike(@)php.net >
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc