Zend Framework titbits

There are a couple of Zend Framework snippets and how-tos I find myself googling over and over again. I have decided to maintain this list and keep adding to it as I go along.

  • Bypassing Zend_Db prepared statements:For complex queries, you may have to write the query out by hand and we recently had to do that. However Zend_Db insists on preparing ALL statements and a PDO bug forced the need to bypass this by accessing the connection object directly.
    To do that run:

    $result = $db->getConnection()->exec('SELECT * FROM users');

    More in the documentation

  • Disable Zend_Layout
    public function ajaxAction() {
    // disable layouts for this action:
    $this->_helper->layout->disableLayout();
    ...
    }
    
  • Disable Zend_ViewRenderer
    public function processingAction() {
    $this->_helper->layout->disableLayout();
    
    // disable the view for this action. e.g. actions that redirect after processing
    $this->_helper->viewRenderer->setNoRender();
    ...
    }
    

No related posts.

This entry was posted in Zend Framework. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>