Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

[DB] returning typed data when fetching rows
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.

Report this thread to moderator Post Follow-up to this message
Old Post
Guillaume Cocatre-Zilgien
08-06-04 01:56 AM


Re: [DB] returning typed data when fetching rows
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 >


Report this thread to moderator Post Follow-up to this message
Old Post
Michael Wallner
08-06-04 01:55 PM


Re: [DB] returning typed data when fetching rows
Michael Wallner wrote:

> Have a look at MDB[2]

Sorry, I accidently crossposted to php.pear.dev. I already replied to
this on that NG. Please fu2 there.

Guillaume

Report this thread to moderator Post Follow-up to this message
Old Post
Guillaume Cocatre-Zilgien
08-06-04 01:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP PEAR Questions and Answers archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:35 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.