1

有可能做这样的事情吗?显然我提供的 echo 语句失败了,有没有办法让它们与 ORM 一起工作?

$record_columns = $records->list_columns();
$records = $records->find_all();
foreach ($record_columns as $column) {
    echo $record->$column;
    echo $record[$column];
}

谢谢,

谢尔伊

4

1 回答 1

2

像这样的东西?对于 Kohana 3.0.x,我正在使用它。我没有用 Kohana 3.1 尝试过,但它应该是类似的:

$result = ORM::factory('my_table')
   ->find_all();

$columns = Database::instance()
   ->list_columns('my_table');

foreach ($result as $row)
{
  foreach ($columns as $key => $value)
  {
    echo $row->{$key};
  }
}
于 2011-07-14T19:14:53.217 回答