Najam-us-Saqib
Najam-us-Saqib

Reputation: 534

Fetch data from data base table in zend framework

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

Answers (3)

Ram Pukar
Ram Pukar

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

Ajith S
Ajith S

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

liyakat
liyakat

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

Related Questions