Ans: In software development, a framework is a defined support structure in which another software project can be organized and developed.
Ans: $this->_helper->layout()->disableLayout();
Disable Zend Layout from controller for Ajax call only
if($this->getRequest()->isXmlHttpRequest()){
$this->_helper->layout()->disableLayout();
}
Ans: function listAction(){
//call another view file file
$this->render("anotherViewFile");
}
Ans: $select = $this->select()
from(array('u' => 'users'), array('id', 'username'))
where('name like ?',"%php%")
where('user_id=?','5')
where('rating<=?',10);
Ans: if($this->getRequest()->isPost()){
//Post
}else{
//Not post
}
Ans: $this->getRequest()->getPost();
Ans: $this->getRequest()->getParams();
Ans: $this->_redirect('/users/login');
Ans: $id= $this->getRequest()->getParam('id');
Ans: class Application_Model_Users extends Zend_Db_Table_Abstract {
protected $_name = "users";
protected $_primary = "id";
}
Ans: $userObj = new Application_Model_Users();
Ans: Zend_Controller_Action
For Example:
class AjaxController extends Zend_Controller_Action {
}
Ans: Zend_Db_Table_Abstract
For Example :
class Application_Model_Users extends Zend_Db_Table_Abstract { }
Ans: In software development, a framework is a defined support structure in which another software project can be organized and developed.
Ans: Framework is a structured system where we get following things
Ans: We set the config in application.ini which is located in application/configs/application.ini.
Ans: It used Front Controller pattern. zend also use singleton pattern.
Ans: Contributor License Agreement
Ans: If you are contributing code as an individual- and not as part of your job at a company- you should sign the individual CLA. If you are contributing code as part of your responsibilities as an employee at a company, you should submit a corporate CLA with the names of all co-workers that you foresee contributing to the project.
Ans: From within a view file: $this->headScript()->appendFile('filename.js'); From within a controller: $this->view->headScript()->appendFile('filename.js'); And then somewhere in your layout you need to echo out your headScript object: $this->headScript();
Ans: Based on the zend authentication it allows the user to access certain actions.
Ans: class Application_Model_Users extends Zend_Db_Table_Abstract
{
protected $_name = 'users';
protected $_primary = 'id';
function updateData($updateData = array()) {
//please update dynamic data
$this->update(array('name' => 'arun', 'type' => 'user'), array('id=?' => 10));
}
}
Ans: class Application_Model_Users extends Zend_Db_Table_Abstract {
protected $_name = 'users';
protected $_primary = 'id';
function users() {
$select = $this->select()
->setIntegrityCheck(false)
->from(array('u' => 'users'), array('name as t_name'))->order('first_name asc')->order('last_name des');
return $this->fetchAll($select);
}
}
Ans: Framework is a structured system
Ans: Configuration can be done in application.ini file in Zend framework. This file in the path application/configs/application.ini.
Ans: if($this->getRequest()->isPost()){ echo "Form posted"; }
Ans: No. Zend Framework was built to use all of the sophisticated object oriented features of PHP 5 and take advantage of significant performance and security enhancements.
Ans: Many PHP applications funnel server requests into a single (or few) PHP source file that sets up the environment and configuration for the application, manages sessions and caching, and invokes the dispatcher for their MVC framework. They can do more, but their main job is to take care of the consistent needs of every page of a web application.
In our Blueprint for PHP Applications, we will have a core bootstrapper that receives all dynamic requests for an application and applies a template for application behavior that we can later extend. It will allow us to later customize the functionality for each unique application.
Ans: Zend Engine is used internally by PHP as a complier and runtime engine. PHP Scripts are loaded into memory and compiled into Zend opcodes.
Ans: Zend engine is like a virtual machine and is an open source, and is known for its role in automating the web using PHP. Zend is named after its developers Zeev and Aandi. Its reliability, performance and extensibility has a significant role in increasing the PHP’s popularity. The Zend Engine II is the heart of PHP 5. It is an open source project and freely available under BSD style license.
Ans: Zend_Controller_Router_Rewrite is the standard framework router. Routing is the process of taking a URI endpoint (that part of the URI which comes after the base URL) and decomposing it into parameters to determine which module, controller, and action of that controller should receive the request. This values of the module, controller, action and other parameters are packaged into a Zend_Controller_Request_Http object which is then processed by Zend_Controller_Dispatcher_Standard. Routing occurs only once: when the request is initially received and before the first controller is dispatched.
Zend_Controller_Router_Rewrite is designed to allow for mod_rewrite-like functionality using pure PHP structures. It is very loosely based on Ruby on Rails routing and does not require any prior knowledge of webserver URL rewriting. It is designed to work with a single Apache mod_rewrite rule.
Ans: Triggered by front controller events
Events bookend each major process of the front controller
Allow automating actions that apply globally
Creating Plugins:
Extend Zend_Controller_Plugin_Abstract
Extend one or more of the event methods
Ans: Caching in Zend Framework is operated by frontends while cache records are stored through backend adapters (File, Sqlite,Memcache...) through a flexible system of IDs and tags. Using those, it is easy to delete specific types of records afterwards (for example: "delete all cache records marked with a given tag").
The core of the module (Zend_Cache_Core) is generic, flexible and configurable. Yet, for your specific needs there are cache frontends that extend Zend_Cache_Core for convenience: Output, File, Function and Class.
Ans: The basic difference between these objects is the ‘scope’ in which they are valid:
a) Zend_Registry : request scope
b) Zend_Session : session scope
a) Zend_Registry is used to store objects/values for the current request. In short, anything that you commit to Registry in index.php can be accessed from other controllers/actions (because EVERY request is first routed to the index.php bootstrapper via the .htaccess file). Config parameters and db parameters are generally prepped for global use using the Zend_Registry object.
b) Zend_Session actually uses PHP sessions. Data stored using Zend_Session can be accessed in different/all pages. So, if you want to create a variable named ‘UserRole’ in the /auth/login script and want it to be accessible in /auth/redirect, you would use Zend_Session.
Ans: At the time of calling AJAX to fetch we need to disable layout.
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
Ans: The model component can vary dramatically in responsibilities and data store from one MVC application to the next.
Ans:
Example1:
Public function indexAction() {
If(condition)
$this->render(‘yourview.phtml’);
Else
Index.phtml;
Example2:
Public function indexAction() {
}
Now in your index.phtml you can have this statement to call other view
$this->action(‘action name’,’controller name’,’module name’,array(‘parameter name’=>’parameter value’));
Ans: From within a view file: $this->headLink()->appendStylesheet(‘filename.css’);
From within a controller: $this->view->headLink()->appendStylesheet(‘filename.css’);
And then somewhere in your layout you need to echo out your headLink object:
headLink();?>
Ans: You have to quote the strings,
$this->getAdapter ()->quote ( );
$select->where ( ” = “, );
OR (If you are using the question mark after equal to sign)
$select->where ( ” = ? “, );
Ans:
Ans:
Ans: The file element needs a special file decorator, which is added by default. When you set your own decorators for file elements, you delete the default decorators.
For example:
$element->setDecorators(array(
array('ViewHelper'),
array('Errors')
));
You should use a File decorator instead of the ViewHelper for the file element, like so:
$element->setDecorators(array(
array('File'),
array('Errors')
));
Ans: You're probably looking for decorators. All forms and form elements in Zend_Form use decorators to render their output.
Ans: The CLA protects all users including individuals, small and medium businesses, and large corporations. By having a CLA in place, we mitigate the risk that companies who claim intellectual property infringement may demand royalties or fees from users of Zend Framework, whether individuals or companies. This is especially important for companies basing their business or products on Zend Framework. The Zend Framework CLA helps to ensure that code and other IP in Zend Framework remains free.
Ans: If you are contributing code as an individual- and not as part of your job at a company- you should sign the individual CLA. If you are contributing code as part of your responsibilities as an employee at a company, you should submit a corporate CLA with the names of all co-workers that you foresee contributing to the project.
Ans: Gives the request & reponse methods by using its sub-classes.
$request = new Zend_Controller_Request_Http()
$response = new Zend_Controller_Response_Http()
Uses of Zend_Date
Date related processing can be done using this component.
Uses of Zend_File_Transfer
it provides extensive support for file uploads and downloads.
Uses of Zend_Db
It is used to doing database related purpose in our appication.
Uses of Zend_Paginator
Doing the pagination in our application.
Uses of Zend_Auth
It is used to authenticate a user.
$auth = Zend_Auth::getInstance();
$results = $auth->authenticate($adapter);
if ($results->isValid()){
}
Zend_Session_Namespace
This is a simple proxy class to use API into the Zend_Session managed $_SESSION Superglobal.