Zend Framework, run query without a view? Zend Framework, run query without a view? database database

Zend Framework, run query without a view?


I use this with calls to AJAX-only actions that I either don't want output or I'm using some other output, like XML or JSON:

// Disable the main layout renderer$this->_helper->layout->disableLayout();// Do not even attempt to render a view$this->_helper->viewRenderer->setNoRender(true);

This has the added benefit of no overhead of redirection if what you are doing has no output/non-HTML output.


To disable view rendering in an action (put this in the specific action. If you want it for the entire controller put it in the init method):

$this->_helper->viewRenderer->setNoRender();

If you are using the layout component of ZF also add this:

$this->_helper->layout->disableLayout();


I could not figure out your code there. in your model you are calling die(). why?it will stop the execution. are you sure about that line? anyway, if you have a controller in Zend Framework and do not need any view, you can turn the view off by this line:

// code in your controller$this->_helper->viewRenderer->setNoRender(true);// the rest of the controller

now the controller will not search for a view script to show to the user.make sure you will call

$this->_redirect() 

after all of your controller job is done.