Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.5.0b5

Request #17165 Move/Explain a function
Submitted: 2010-02-26 03:00 UTC
From: rprandini Assigned:
Status: Open Package: MDB2 (version 2.5.0b2)
PHP Version: 5.3.0 OS: win 2000 sp4
Roadmaps: (Not assigned)    
Subscription  


 [2010-02-26 03:00 UTC] rprandini (Riccardo Prandini)
Description: ------------ I'd like to fetch my row as object as. ..... class VOAuthor { public var $id_aut; public var $fname_aut; public var $lname_aut; public var $birth_Date; } ..... ..... //MYSQL OLD STYLE $result = mysql_query($query); $ret = array(); while ($row = mysql_fetch_object($result, "VOAuthor")) { $ret[] = $row; } mysql_free_result($result); ...... Test script: --------------- No script i don't understand how to do it. on mdb2 manual there is page dedicated at connection settings http://pear.php.net/manual/en/package.database.mdb2.intro-connect.php in option array reported in many example there is interesting fetch_class string class to use when fetch mode object is used So i set $options = array( 'debug' => 2, 'result_buffering' => false, 'fetch_class' =>"VOAuthor" ); Now the problem i'd like to obtain a the birthDate as datetime, http://www.php.net/manual/en/class.datetime.php so i think another option must be used: datatype_map array map user defined datatypes to other primitive datatypes, but how to???? The second thing is: if i do multiple query select1, selct2 , select3, obtaining each time different row schema (depending on selected fields) that i wont to convert in a VOAuthor Object, MYCustom Object, how to change the option before each select. Expected result: ---------------- I expect an array of VOAuthor i explain because i wont those thing so complicate, because i use MDB2, in combination with SABREAmf, 2 Pear Tools, But Sabre need Complex Dataype to convert info from PHP to Flex for example Date. I think that if you could explain how to use two optional param that i indicated to obtain a a custom Object it's a gratintegration between sabre and mdb2. Another motivation is a performantìce tip i explain better thi point in Actual Result I think also that if fech object coud recive class as argument thi can be a usability enhancement; anyway this is not primary requirement and nee a new interface (i dislike function intrface changing withiut adding new functionality so i think this is not so important) Actual result: -------------- Actually i use MDB2_FETCHMODE_ASSOC renemaing duplicate field in join than for each row i convert it in a new VOAuthor object. For 1000 record this is an huge effort (not for me but for php) an it's not so simple to manage high amount of record 20000 or 200000.

Comments