You are here: Re: [SMARTY] direct way to handle mysql result sets (via resource id) with smarty « Smarty Templates Posts « IT news, forums, messages
Re: [SMARTY] direct way to handle mysql result sets (via resource id) with smarty

Posted by Jφrg Hermsdorf on 05/02/05 20:47

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 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 ;-)

--- Vicente Werner <vwerner@gmail.com> schrieb:
> Well at this moment there's no such function, you'll
> need to make your
> own function/block/... plugin (because there're many
> ways to do it) if
> you want to do it that way. It's not difficult to do
> if you want a
> very specialized function -for example, if it only
> has to work with
> that table- and a bit more when using it for more
> general cases.
>
> A more elegant approach will be to instaurate a
> pagination, I doubt
> that 2000 rows on the screen are useful, better to
> show say 50 per
> page , and give the option to go to another page.
>
> Going a bit off topic in my answer, I suggest you
> move forward to
> adodb or another db abstraction clases, it will
> bring you aditional
> features in the long run (for example if you
> eventually upgrade to
> mysql 4.1 your application as it is will be broken)
> that overcome any
> disavantage at this point and ease implementation of
> features like
> paging.
>
> On 5/2/05, JΓΆrg Hermsdorf <funtasyspace@yahoo.com>
> wrote:
> > Hello List,
> > I would like to know if there is an easier way to
> > handle MySQL result sets in smarty? Currently I
> only
> > know of the approach to prepare an array out of
> the
> > resource id returned by mysql_query() :
> >
> > ...
> > $result = mysql_query('SELECT * FROM ...');
> > while ($row = mysql_fetch_assoc($result))
> > {
> > $result_array[] = $row;
> > }
> > $smarty->assign('results', $result_array);
> >
> > Then I can use the result set within the {foreach
> > item=result from=$result_array}{/foreach}
> function.
> >
> > But I'm looking for another way, where I can
> directly
> > assign the resource like this:
> >
> > $smarty->assign('results', mysql_query('SELECT *
> FROM
> > ...'));
> >
> > ... is there a foreach-like smarty-plugin-function
> > that can handle a "resource id" instead of an
> array?
> >
> > Thanks, JΓΆrg.
> >
>




___________________________________________________________
Gesendet von Yahoo! Mail - Jetzt mit 250MB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de

 

Navigation:

[Reply to this 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

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация