Reputation: 534
I am new to zend framework and in the process of learning. I want to know that how we can fetch whole data of a table in zend framework and display it on the screen. I saw lots of tutorials but can't understand the logic behind this.
If someone can give me small tutorial regarding this that would be very helpful.
I am using these classes
Model
Application_Model_DbTable_Form extends Zend_Db_Table_Abstract{
protected $_name = 'register';
protected $_primary = 'firstName';
}
class Application_Model_Sign {
private $_dbTable;
public function __construct() {
$this->_dbTable = new Application_Model_DbTable_Form();
}
}
Controller
public function outAction() {
//action body
}
View
<html>
<body>
<table>
<tr>
<th>First Name</th>
<th>Middle Name</th>
<th>Last Name</th>
<th>Gender</th>
<th>Job Type</th>
</tr>
</table>
</body>
</html>
Upvotes: 1
Views: 3272
Reputation: 1621
:: Model
class Default_Model_Deployment extends Zend_Db_Table_Abstract {
protected $_name = 'tbl_deployment';
protected $_primary = 'id';
public function allData(){
$db = Zend_Db_Table::getDefaultAdapter();
$sql = "SELECT * FROM tbl_deployment";
$result = $db->query($sql);
$row = $result->fetchAll(); // TO RENDER ALL DATA IN TABLE.
return $row;
}
}
:: Controller
class Default_DeploymentController extends Zend_Controller_Action {
public function indexAction(){
$model = new Default_Model_Deployment();
$renderData = $model->allData();
$this->view->assign(array('recDeploy'=>$renderData));
}
} // To close class
:: View
print '<pre>';print_r($this->recDeploy);print '</pre>';die;
Upvotes: 1
Reputation: 2917
Please check this links
Hope this will help you as a begginner
The first link tells you the proper folder structure of Zend MVC
Upvotes: 0
Reputation: 11853
here i can give you sample tutorial for that you can easily understand how can we manipulate data in zend framework
http://akrabat.com/zend-framework-tutorial/
just download and install in you local.
also see
http://mishrarakesh.blogspot.in/2010/12/zend-framework-111-simple-examples.html
for better understanding.
hope this will sure help you.
Upvotes: 1