|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
gremio10 Smarty Rookie
Joined: 28 Jan 2011 Posts: 11
|
Posted: Wed Mar 16, 2011 2:20 am Post subject: Catchable fatal error: Object of class stdClass could not be |
|
|
Hello,
I use the PDO conection, and when I make a Query with fetchAll he returns a stdClass, how I do to make a foreach?
I make like this:
php.:
Code: | $names = $Sql->findAll("User",array("select" => array("name","email")));
$smarty->assign("name",$names);
$smarty->display("index.tpl"); |
tpl.:
Code: | {foreach from=$name item=names}
{$names}
{/foreach} |
my fetchAll().:
Code: | public function fetchAll(){
try{
return $this->qry->fetchAll( PDO::FETCH_OBJ );
}catch( PDOException $e ){
print( $e->getMessage() . " - [ " . $e->getCode() . " ] " );
}
} |
Thank You. |
|
Back to top |
|
scdgro Smarty Regular
Joined: 24 May 2003 Posts: 39 Location: Netherlands
|
Posted: Sat Mar 19, 2011 12:34 pm Post subject: |
|
|
Don't know if this is what you mean :
Smarty 2 syntax :
Code: |
{foreach from=$name item=names}
{$names->foo}
{$names->bar}
{/foreach}
|
Smarty 3 syntax :
Code: |
{foreach $name as $names}
{$names->foo}
{$names->bar}
{/foreach}
|
|
|
Back to top |
|
|
|
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
|