Reply to Re: [SMARTY] looping over an array of objects

Your name:

Reply:


Posted by boots on 11/01/05 17:21

--- Isaac Vetter <ivetter@math.purdue.edu> wrote:
> I'm setting up propel (http://propel.phpdb.org/), which is an
> object-relational mapper, like DB_Object. So, database queries
> return
> objects, many of which need to be passed to a smarty template for
> display. I could manually move each relevant property into an array
> ($ary[$i]['id'] = $aryOfObj[$i]->getId()), but ... I really don't
> want
> to have to do that.
>
> The smarty documentation implies that an array of objects can be
> looped
> over, if the array is assign()'d or assign_by_ref()'d. This doesn't
> seem to be working for me. Can someone confirm that this works?

An array of objects is just an array and certainly works. If you are
intending to iterate over an object as an array you can do that as well
as long as you have a fairly recent version of Smarty and use foreach.

best,
boots

> If this doesn't work, I'm thinking of writing/using code that uses
> reflection to automatically call property getters to create the
> smarty-required multi-dimensional arrays, any suggestions?
>
> Much Thanks,
>
> Isaac Vetter




__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com

[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

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