[DB] returning typed data when fetching rows

From: Date: Thu, 05 Aug 2004 16:35:56 +0000
Subject: [DB] returning typed data when fetching rows
Groups: php.pear.qa 
Request: Send a blank email to pear-qa+get-1790@lists.php.net to get a copy of this message
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.

« previous php.pear.qa (#1790) next »