Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Two identical for each loops don't work together

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Tuplad
Smarty n00b


Joined: 13 May 2011
Posts: 3

PostPosted: Thu Jun 23, 2011 2:34 pm    Post subject: Two identical for each loops don't work together Reply with quote

No error, nothing... the second just doesn't show up. What to do ?

clubs.tpl : http://pastebin.com/UQNHCpib

clubs.php : http://pastebin.com/G1YTCyM7

I'd find it stupid to rewrite the same piece of code but with an other varname, anyone knows what's going on ?
Back to top
View user's profile Send private message
rodneyrehm
Administrator


Joined: 30 Mar 2007
Posts: 674
Location: Germany, border to Switzerland

PostPosted: Thu Jun 23, 2011 3:53 pm    Post subject: Reply with quote

change
Code:
$smarty->assign('prov', $prov);

to
Code:
$smarty->assign('prov', $prov->fetchAll());

and you'll assign an array that can be iterated twice. The PDOStatement cannot, as there is no way to reset the cursor.

besides that, are you sure you know what you're doing setting PDO::FETCH_LAZY? Read carefully:
Quote:
Specifies that the fetch method shall return each row as an object with variable names that correspond to the column names returned in the result set. PDO::FETCH_LAZY creates the object variable names as they are accessed.

so some object should be created, nothing wrong with that. But why are you treating it as an array in your templates? there's no, absolutely no, benefit from this.
Back to top
View user's profile Send private message Visit poster's website
Tuplad
Smarty n00b


Joined: 13 May 2011
Posts: 3

PostPosted: Sat Jun 25, 2011 11:30 am    Post subject: Reply with quote

Thanks a lot, globe!

To be honest, I didn't really know what I was doing with LAZY, I've removed it!
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP