Monday, 6 May 2019

Zend 3 Interview Questions and Answers

Zend 3 Interview Questions and Answers

Question: How to print MySql query in zend framework?
$select = $this->sql->select();
echo $select->from('users')
        ->columns(array('id', 'first_name', 'last_name', 'email', 'status', 'total_events' => (`10`)))
        ->where($conds)
        ->order($orderBy);



Question: What are different type of route?
Literal routes: a literal route is one that exactly matches a specific string.
Segment routes: Segment routes allow you to define routes with variable parameters.


Question: How to disabled layout from controller in Zend Framework 3?
$view= new ViewModel();
$view->setTerminal(true);
return $view;



Question: How to print Sql Query in Zend3?
echo  $select->getSqlString($this->sql->getAdapter()->getPlatform(),\Zend\Db\Adapter\Adapter::QUERY_MODE_EXECUTE);



Question: Give example of Inner join, Left Join and Right join?
Inner join
$select = $this->sql->select();
$select->from(array('u'=>'users'))
        ->columns(array('id','email'))
        ->join(array('eq'=>'event_qualifiers'),"eq.user_id=u.id",array('total_events','event_type'));


Left join
$select = $this->sql->select();
$select->from(array('u'=>'users'))
        ->columns(array('id','email'))
        ->join(array('eq'=>'event_qualifiers'),"eq.user_id=u.id",array('total_events','event_type'),$select::JOIN_LEFT);


Right join
$select = $this->sql->select();
$select->from(array('u'=>'users'))
        ->columns(array('id','email'))
        ->join(array('eq'=>'event_qualifiers'),"eq.user_id=u.id",array('total_events','event_type'),$select::JOIN_RIGHT);


Question: How to autoload new module?
Once you have created the file structure for new module
1) Open the composer.json file.
2. Add the following line in psr-4 under autoload.
"Newmodule\\": "module/Newmodule/src/"


like below
"autoload": {
    "psr-4": {
        "Application\\": "module/Application/src/",
        "Album\\": "module/Album/src/"
    }
}



3. Execute following command
composer dump-autoload



Question: What are two components for databases?
A) One approach is to have "model classes" like Album represent each entity in your application
and then use mapper objects that load and save entities to the database.
B) Object-Relational Mapping (ORM) technology, such as Doctrine or Propel.


Question: What is use of config/modules.config.php?
We tell the ModuleManager that what module need to load with use of modules.config.php.


Question: What is Zend engine?
Zend Engine is a set of various components, which is used internally by PHP as a compiler.


Question: What are Decorators in the Zend framework?
Zend framework utilizes the decorator pattern to render elements and forms.


Question: What are Plugins in the Zend framework?
Zend Framework makes heavy use of plugin architectures.
Plugins allow for easy extensibility and customization of the framework while keeping your code separate from Zend Framework's code.


Question: How to check post method in zend framework?
if($this->getRequest()->isPost()){
}



Question: How to get post method in zend framework?
$postData = $this->getRequest()->getPost();



Question: How to get all GET data?
$this->getRequest()->getParams();



Question: How to redirect to another page from controller?
$this->_redirect("/users/login");



Question: What is Event Manager?
It gives the ability to create event based programming. This helps to create, inject and manage new events.


Question: What is Service Manager?
It gives the ability to consume any services (PHP classes) from anywhere with a little effort.


Question: What is Module Manager?
Ability to convert a collection of PHP classes with similar functionality into a single unit called as a module. The newly created modules can be used, maintained and configured as a single unit.