Reply to Re: [SMARTY] direct way to handle mysql result sets (via resource id) with smarty

Your name:

Reply:


Posted by Vicente Werner on 05/04/05 16:38

Well you're not getting twice the data as is not doubled one of the
fields is just a reference to the other one. It's possible to change
that behaviour trough the $ADODB_FETCH_MODE global var see
http://phplens.com/lens/adodb/docs-adodb.htm#adodb_fetch_mode as mysql
by default gives the results that way.

As for the difference between those functions: GetAssoc & GetArray ARE
the same function (look at the adodb docs) and the difference between
GetAssoc & GetArray won't be seen unless you have your fetch_mode as
ADODB_FETCH_NUM and you want an asociative array.

Vicente Werner
Lead Developer
Dinahosting S.L.
www.dinahosting.com

On 5/3/05, Jörg Hermsdorf <funtasyspace@yahoo.com> 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:
> > > OK OK, I have to mention, that I actually do
> > > 'pagination', so I won't have such large result
> > sets
> > > ;-) I just wanted to know what the most elegant
> > way to
> > > handle results is, because I somehow didn't feel
> > that
> > > comfortable 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...
> > what
> > > would you recommend me? I don't have time to
> > evaluate
> > > all 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!
> >
>
> ___________________________________________________________
> Gesendet von Yahoo! Mail - Jetzt mit 250MB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация