Zend Framework Interview Questions and Answers
1.What is a Framework?
In software development, a framework is a defined support structure in which another software project can be organized and developed.
- An abstract design
- Set of common functionality
- Developed for a particular domain
2.How to disable layout from controller?
$this->_helper->layout()->disableLayout();
Disable Zend Layout from controller for Ajax call only
if($this->getRequest()->isXmlHttpRequest()){
if($this->getRequest()->isXmlHttpRequest()){
$this->_helper->layout()->disableLayout();
}
3.How to change the View render file from controller?
function listAction(){
function listAction(){
//call another view file file
$this->render(“anotherViewFile”);
}
4.How to protect your site from sql injection in zend when using select query?
$select = $this->select()
$select = $this->select()
from(array(‘u’ => ‘users’), array(‘id’, ‘username’))
where(‘name like ?’,”%php%”)
where(‘user_id=?’,’5′)
where(‘rating<=?’,10);
5.How to check post method in zend framework?
if($this->getRequest()->isPost()){
if($this->getRequest()->isPost()){
//Post
}else{
//Not post
}
6.How to get all POST data?
$this->getRequest()->getPost();
$this->getRequest()->getPost();
7.How to get all GET data?
$this->getRequest()->getParams();
8.How to redirect to another page from controller?
$this->_redirect(‘/users/login’);
$this->_redirect(‘/users/login’);
9.How to get variable’s value from get?
$id= $this->getRequest()->getParam(‘id’);
$id= $this->getRequest()->getParam(‘id’);
10.Create Model file in zend framework?
class Application_Model_Users extends Zend_Db_Table_Abstract {
protected $_name = “users”;
protected $_primary = “id”;
}
Comments
Post a Comment