【发布时间】:2011-12-12 21:59:54
【问题描述】:
如何在 Kohana 中使返回的 ORM 结果对象适合在 RSS 提要帮助程序的 items 参数中使用?
例如,如果想将我所有的用户帖子添加到提要中。
$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);
【问题讨论】:
标签: rss kohana kohana-3 kohana-orm