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

Get values from PDO query and pass the fields into an array

 
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 -> Tips and Tricks
View previous topic :: View next topic  
Author Message
s2xi
Smarty Rookie


Joined: 02 Mar 2011
Posts: 8

PostPosted: Sat Apr 16, 2011 5:06 am    Post subject: Get values from PDO query and pass the fields into an array Reply with quote

How can I do the following.

1. Get values from a PDO statement (I have already done this)
2. Pass each value as an array object that I can construct like this

(this is an insert from my class file that handles the connection via PDO and data manipulation)

$r = $this->query($sql);
foreach($r as $m)
{
$contents = $smarty->fetch($path_to_module);
$smarty->assign($m['module_name']."_module", $contents)
}

is this the correct way to approach this?

My goal is to not do any logic in the template file but rather just simply insert variables like

{$navigation_module}
{$search_module}
Back to top
View user's profile Send private message
s2xi
Smarty Rookie


Joined: 02 Mar 2011
Posts: 8

PostPosted: Sat Apr 16, 2011 9:00 am    Post subject: Reply with quote

aaah, i see. wish i could understand the thread but i got it by looking at the code snippet. Gave me the idea! thank you my friend.
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 -> Tips and Tricks 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