Re: [SMARTY] direct way to handle mysql result sets (via resource id) with smarty
| From: | pete M | Date: | Wed, 04 May 2005 13:06:19 +0000 |
| Subject: | Re: [SMARTY] direct way to handle mysql result sets (via resource id) with smarty | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-12578@lists.php.net to get a copy of this message | ||
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
http://phplens.com/lens/adodb/docs-adodb.htm#adodb_fetch_mode
this will then only return assoc array
;-)
Jörg Hermsdorf wrote:
Thanks to all of you for the infos so far! I migrated to ADOdb today, but I experience a very strange problem. No matter whether I call the GetAll(), GetArray() or GetAssoc() function of a recordset, I always get an 2-dimensional array, where the 2nd dimension consists of indexed AND associated arrays... therefore I always get the double amount of fields. By the way, there's no visible difference between the three functions. Example: // table| column1 | column2 | column3 | ... | column N---------------------------------------------------- row 0 | value01 | value02 | value03 | ... | value0N row 1 | value11 | value12 | ....................... ... | ........................................... row N | valueN1 | ................................. $rs = &$db->Excecute("SELECT * FROM table;"); print_r($rs->GetArray()) or print_r($rs->GetAssoc()) or print_r($rs->GetAll()): Array ( [0] => Array ( [0] => value01 [column1] => value01 [1] => value02 [column2] => value02 ...)[1] => Array ( [0] => value11 [column1] =>value11 [1] => value12 [column2] => value12 ...)... )Any idea what causes this strange behavior? I'm running MySQL 4.1+ --- Vicente Werner <vwerner@gmail.com> schrieb:On 5/2/05, Jörg Hermsdorf <funtasyspace@yahoo.com> wrote:___________________________________________________________ Gesendet von Yahoo! Mail - Jetzt mit 250MB Speicher kostenlos - Hier anmelden: http://mail.yahoo.deOK OK, I have to mention, that I actually do 'pagination', so I won't have such large resultsets;-) I just wanted to know what the most elegantway tohandle results is, because I somehow didn't feelthatcomfortable transfering result sets into arrays!I think that arrays are the most elegant way, it's easy to add aditional fields without breaking the code and tweaking them dosn't have much cost, while dealing with resouces is not portable, you need specific code for each kind of recordset you get from the database, and not much faster. Keep in mind that on web apps is probably better to ate 1Mb ram for 0.01 secs that spending 0.1 secs fetching data from a database just to avoid ram.I also consider moving to a different database abstraction layer like pear::db or something...whatwould you recommend me? I don't have time toevaluateall the possibilities ;-)I find that the best one after cheking several ones, is adodb, maybe metabase has some aditional features, but adodb is very very clean, it has a very straight object model that's easy to understand and is FAST!