>[code]
>foreach ($results as $result) {
> $tbl = new MyDbTable();
> $rowClass = $tbl->getRowClass();
> $resultObj = new $rowClass(array('data' =>
>get_object_vars($result), 'table' => $tbl));
>}
>[/code]
Since you pretty much have to assign a table anyway to get any usefulness from
your custom row class, how about doing one of the following so that your not
instantiating a new table in each iteration.
$results = $adapter->query($select)->fetchAll();
$config = array(
'data' => $results,
'table' => new Zend_Db_Table_Abstract(array('name' => 'myTable'),
'rowClass' => 'My_Custom_Row_Class'
);
$rowSet = new Zend_Db_Table_Rowset($config);
However... this seems like a a pretty convoluted way of doing the following.
$config = array(
'name' => 'myTable',
'rowClass => 'My_Custom_Row_Class'
);
$table new Zend_Db_Table_Abstract($config);
$rowSet = $table->fetchAll($select);
没有评论:
发表评论