0
我想實現一個網站使用datatable和zend框架從mysql數據庫中獲取數據。這裏是我的view.phtmlZend框架使用數據表
<table cellpadding="0" cellspacing="0" border="0" class="display" id="shadow-table" width="100%">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
<tbody bgcolor="#E2E4FF">
</tbody>
Controller.php這樣
public function getdataAction() {
$this->_helper->layout()->disableLayout();
$shadow = new Admin_Model_Shadow();
$result = $shadow->listall();
$this->view->a = $result;
json_encode($result);
}
和我model.php
class Admin_Model_Shadow extends Zend_Db_Table_Abstract {
protected $_name = "users";
protected $_primary = "user_id";
public function listall() {
$db = $this->getDefaultAdapter();
$query = $db->select()
->from('users',array('user_id','name','email');
return $db->fetchAll($query);
}
}
現在我想通過數據表顯示在view.phtml的$result
。我怎樣才能做到這一點?
謝謝你的回覆!但我對此很新,你能否給我一個類似於我的代碼的簡單例子。 – user2986673