-1
如何在Kohana中使返回的ORM結果對象適用於RSS饋送助手的items參數?使Kohana ORM結果對象適用於RSS助手
例如,如果想要將所有用戶帖子添加到供稿中。
$posts = ORM::factory('posts')->find_all();
feed::create()
中使用的items參數需要是多維數組。有沒有一種簡單的方法來將返回的對象格式化爲多維數組?
這裏是我到目前爲止有:
$items = array();
$info = array('title' => 'test feed');
$posts = ORM::factory('post')->find_all();
foreach ($posts as $post)
{
$item = array('title' => $post->title,
'summary' => $post->description,
'pubDate' => $post->date);
$items[] = $item;
}
$this->request->response = Feed::create($info, $items);