DB_DataObject and Smarty
| From: | Chris Boget | Date: | Thu, 05 Oct 2006 18:30:29 +0000 |
| Subject: | DB_DataObject and Smarty | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-13491@lists.php.net to get a copy of this message | ||
Does anyone know of any tutorials out there that show how I can get smarty working with DBDO? I've searched but haven't been able to come up with anything beyond using DB::getAll() method. I'd rather stay away from using that if at all possible. I'd rather use DBDO::find(). Here's one (among many) attempt I made to get it to work:
sandbox.php:
<?php
$users = new Users();
$users->country = 'USA';
$users->limit( 10 );
$users->find();
$smarty = new Smarty();
$smarty->assign( 'users', $users );
$smarty->display( 'sandbox.tpl' );
?>
sandbox.tpl
<html><head><title></title></head><body>
{section name=bar loop=$users}
Current User: {$users[bar].uid}<br>
{/section}
</body></html>
but doing that gives me an error saying that it cannot use object of type Users as array. Am I just doing it wrong? Do I need to implement the iterator interface in the Users class?
If someone can offer any pointers as to what I'm doing wrong or if you can point me to a howto/tutorial on the web, that'd be awesome!
thnx,
Chris