I dont see a problem with using this to be honest.
Obviously you'll want to move the table creation out of the loop, or use the rowset init as suggested by Graham Anderson which is the method I'd use.
It really isnt that messy. Or, you could extend the statement results class used by your database adapter and provide a function for the result to do it all. ($db->query($select)->toRowset('rowsetclassname', 'tablename'); or somesuch)
T
[code]
foreach ($results as $result) {
$tbl = new MyDbTable();
$rowClass = $tbl->getRowClass();
$resultObj = new $rowClass(array('data' =>
get_object_vars($result), 'table' => $tbl));
}
[/code]
My $resultObj now has the proper methods attached as well as goes
through the custom rowClass init (which was the crucial part).
没有评论:
发表评论