Hello,

I am messing around a little bit with NotORM. But trying to find a nice way to automatically repeat the result and put i.e. a html list around it.

See my object:
PHP Code:
<?PHP

class RepeaterList
{
    private 
$List;
    private 
$html;
    public function 
__construct($data$html)
    {
        
$this->html $html;
        foreach(
$data as $item) { 
            
$html = eval($this->html);
            
$this->List .= $html;
        }
    }
    public function 
render()
    {
        return(
$this->List);    
    }
}

?>
And here is how I call it.

PHP Code:
<?PHP $dsn "mysql:dbname=db;host=localhost";
$pdo = new PDO($dsn"username""password");
$db = new NotORM($pdo);
$articles $db->article();
$articleList = new RepeaterList($articles,'?><li><?php echo $item["title"]; ?>, <?php echo $item["url"]; ?>, <?php echo $item->category["name"]; ?></li>');
print(
$articleList->render());
?>
As you can see, I am using the function eval() on the html I send to the object. Actually I don't want to use it. I'll have to put php opening and closing tags in my html and I don't like to use eval().

I was thinking I could do something like:
PHP Code:
<?PHP
$articleList 
= new RepeaterList($articles,'<li>{item["title"]}, {item["url"]}, {item->category["name"]}</li>');
?>
And then with regexp retrieve all items enclosed in {} and replace them with the contents of the variable $$retrievedinnerstring.
str_replace($retrievedstring,$$retrievedinnerstring,$html).

But I don't think that is a good way either. Is the some better way I can use to insert the data in the html?

ps. NotORM returns objects.