简体   繁体   English

在kostache中显示结果

[英]display results in kostache

Ok I just started kostache and I would like to display the results i got from the database using orm in kohana 3.3. 好的,我刚刚启动kostache,我想使用kohana 3.3中的orm显示从数据库中获得的结果。 I know how to display them using foreach statement but when using kostache it's way different. 我知道如何使用foreach语句显示它们,但是使用kostache时却有所不同。 So here's my code. 所以这是我的代码。

APPATH/classes/controller/album.php APPATH /类/控制器/album.php

class Controller_Album extends Controller 
{
    public function action_index()
    {
        $view = Kostache_Layout::factory();
        $this->response->body($view->render(new View_Pages_Album_List));
    }
}

APPATH/classes/view/pages/album/list.php APPATH / classes / view / pages / album / list.php

class View_Pages_Album_List {

    public $title = 'List of Music';

    public function album_list()
    {

        $albums = ORM::factory('Album_Information')->find_all();
        return $albums;

    }

}

APPATH/templates/pages/album/list.mustache APPATH /模板/页面/专辑/列表。小胡子

{{album_list}}

How would i display the resulst?. 我将如何显示结果? How would you do this in kostache? 您将如何在Kostache中做到这一点?

Thanks and more power. 感谢和更多的力量。

Well Nevermind I got it working.. 好吧,没关系,我已经开始运作了。

public function album_list()
    {

        $albums = ORM::factory('Album_Information')->find_all();
        $album_info = array();
        foreach ($albums as $a)
        {
            $album = array('album' => array('artist' => $a->Artist, 'album_name' => $a->Album_Name,));
            $album_info[] = $album;

        }
        return $album_info;

    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM