Re: MDB2 and QuickForm

From: Date: Mon, 05 Jun 2006 14:03:39 +0000
Subject: Re: MDB2 and QuickForm
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-24251@lists.php.net to get a copy of this message
Lukas Smith wrote:
Köteles Zoltán wrote:
$result = $mdb2->queryAll($query);
<snip>
$select->loadDbResult($result, 'country_name', 'country_id');
I dont know Quickforms, but from a quick scan of the source and documentation I think you need to use loadArray: http://pear.php.net/manual/en/package.html.html-quickform.html-quickform-select.loadarray.php @Alexey: loadDbResult() only works with DB .. I can work on a solution to would make things work with MDB2 as well. In that case you would however need to use query() and not queryAll(). regards, Lukas Thanks for your quick answer, but if I'm using the query (and var_dump() the result) I see that:
object(MDB2_BufferedResult_mysql)#6 (9) { ["db"]=> object(MDB2_Driver_mysql)#5 (28) { ["escape_quotes"]=> string(1) "\" ["db_index"]=> int(1) ["dsn"]=> array(10) { ["phptype"]=> string(5) "mysql" ["dbsyntax"]=> string(5) "mysql" ["username"]=> string(4) "root" ["password"]=> string(0) "" ["protocol"]=> bool(false) ["hostspec"]=> string(9) "localhost" ["port"]=> bool(false) ["socket"]=> bool(false) ["database"]=> bool(false) ["mode"]=> bool(false) } ["connected_dsn"]=> array(10) { ["phptype"]=> string(5) "mysql" ["dbsyntax"]=> string(5) "mysql" ["username"]=> string(4) "root" ["password"]=> string(0) "" ["protocol"]=> bool(false) ["hostspec"]=> string(9) "localhost" ["port"]=> bool(false) ["socket"]=> bool(false) ["database"]=> bool(false) ["mode"]=> bool(false) } ["connection"]=> resource(12) of type (mysql link) ["opened_persistent"]=> bool(false) ["database_name"]=> string(9) "bookstore" ["connected_database_name"]=> string(9) "bookstore" ["connected_server_info"]=> string(10) "5.0.21-log" ["supported"]=> array(15) { ["sequences"]=> string(8) "emulated" ["indexes"]=> bool(true) ["affected_rows"]=> bool(true) ["summary_functions"]=> bool(true) ["order_by_text"]=> bool(true) ["transactions"]=> bool(false) ["current_id"]=> string(8) "emulated" ["limit_queries"]=> bool(true) ["LOBs"]=> bool(true) ["replace"]=> bool(true) ["sub_selects"]=> bool(true) ["auto_increment"]=> bool(true) ["primary_key"]=> bool(true) ["result_introspection"]=> bool(true) ["prepared_statements"]=> bool(true) } ["options"]=> array(24) { ["ssl"]=> bool(false) ["field_case"]=> int(0) ["disable_query"]=> bool(false) ["result_class"]=> string(14) "MDB2_Result_%s" ["buffered_result_class"]=> string(22) "MDB2_BufferedResult_%s" ["result_wrap_class"]=> bool(false) ["result_buffering"]=> bool(true) ["fetch_class"]=> string(8) "stdClass" ["persistent"]=> bool(false) ["debug"]=> int(2) ["debug_handler"]=> string(23) "MDB2_defaultDebugOutput" ["default_text_field_length"]=> int(4096) ["lob_buffer_length"]=> int(8192) ["log_line_break"]=> string(1) " " ["idxname_format"]=> string(6) "%s_idx" ["seqname_format"]=> string(6) "%s_seq" ["seqcol_name"]=> string(8) "sequence" ["quote_identifier"]=> bool(false) ["use_transactions"]=> bool(false) ["decimal_places"]=> int(2) ["portability"]=> int(127) ["modules"]=> array(6) { ["ex"]=> string(8) "Extended" ["dt"]=> string(8) "Datatype" ["mg"]=> string(7) "Manager" ["rv"]=> string(7) "Reverse" ["na"]=> string(6) "Native" ["fc"]=> string(8) "Function" } ["emulate_prepared"]=> bool(false) ["default_table_type"]=> NULL } ["warnings"]=> array(0) { } ["debug_output"]=> string(153) "query(1): SELECT c.country_id AS country_id, c.country_name AS country_name FROM bookstore_books_country AS c ORDER BY c.country_name " ["in_transaction"]=> bool(false) ["offset"]=> int(0) ["limit"]=> int(0) ["phptype"]=> string(5) "mysql" ["dbsyntax"]=> string(5) "mysql" ["last_query"]=> string(142) " SELECT c.country_id AS country_id, c.country_name AS country_name FROM bookstore_books_country AS c ORDER BY c.country_name " ["fetchmode"]=> int(1) ["modules"]=> array(0) { } ["destructor_registered"]=> bool(true) ["_debug"]=> bool(false) ["_default_error_mode"]=> NULL ["_default_error_options"]=> NULL ["_default_error_handler"]=> string(0) "" ["_error_class"]=> string(10) "PEAR_Error" ["_expected_errors"]=> array(0) { } } ["result"]=> &resource(21) of type (mysql result) ["rownum"]=> int(-1) ["types"]=> array(0) { } ["values"]=> array(0) { } ["offset"]=> int(0) ["offset_count"]=> int(0) ["limit"]=> int(0) ["column_names"]=> NULL } And the select list is empty. If I'm using queryAll I see that: array(194) { [0]=> array(2) { [0]=> string(1) "1" [1]=> string(11) "Afganisztán" } [1]=> array(2) { [0]=> string(1) "2" [1]=> string(7) "Albánia" } [2]=> array(2) { [0]=> string(1) "3" [1]=> string(7) "Algéria" } [3]=> array(2) { [0]=> string(1) "4" [1]=> string(25) "Amerikai Egyesült Államok" } [4]=> array(2) ...... ant the select list is an array but I don't see the list of countries only just string Array. I test it: $result = $mdb2->query($result); $array = fetchAll(); $select->loadArray($array); But same result like with the queryAll(). ZoTyA

« previous php.pear.general (#24251) next »