2012-11-04 34 views
-2

我想問我doophp以什麼方式可以將我的db數據從模型控制器返回到我的視圖。返回分貝數據doophp

這裏是myController的:

`class CategoryController extends DooController { 
    public function Index(){ 
     Doo::loadModel('Category'); 
     $category = new Category; 
     Doo::db()->find($category, array('limit'=>1)); 
     $this->view()->render('Category/Index', $category); 
    } 
} 

而且我有例子的圖(category.html)是這樣的:

<!DOCTYPE html> 
<html> 
    <head> 
     <title></title> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    </head> 
    <body> 
     <div>{{category.categoryname}}</div> 
    </body> 
</html>` 
+0

你做了什麼?在你的問題和更多細節中添加一些代碼示例。 –

+0

你能幫我怎麼看我的db數據到我的視圖..? – user1658429

+0

如果你想添加細節到你的問題,你可以'編輯'它。不要將它寫在評論部分,它是不可讀的。我爲你完成了這項工作。 –

回答

1

的eseast方式做到這一點是:

class CategoryController extends DooController { 
    public function Index(){ 
     Doo::loadModel('Category'); 
     $category = new Category; 
     Doo::db()->find($category, array('limit'=>1)); 
     $this->view()->renderc('Category/Index', array("category" => $category)); 
    } 
} 

然後category.php

<!DOCTYPE html> 
<html> 
    <head> 
     <title></title> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    </head> 
    <body> 
     <div><?php echo $this->data['category']->categoryname; ?></div> 
    </body> 
</html>`