24 December 2009 ~ 0 Comments

Zend Caveats

Zend Caveats

Ever gets frustrated during your coding? I’m pretty sure the answer is a big YES especially if you’re new with the programming language you’re trying to develop or you might have forgotten the old programming language you used to. Likewise, most of the time we get frustrated when there is a stumbling block during your development especially when the deadline is imminent. The expression “Argh!!” or banging on a table are common to convey the frustration. :)

Anyway, here I’m going to share with some of my encounters that I can still recall during my past development using Zend Framework.

Controller

  • $this->_forward() somehow reset protected variables upon two consecutive executions. Unfortunately I am unable to recall the exact situation during the encounter.
  • Avoid using Zend_Form_Element_Submit->setAttrib('value','submit') but rather to use Zend_Form_Element_Submit->setValue().
  • $this->url( array( 'controler' => 'control', 'action' => 'action' )) will only set or replace the specified parameters and retain other parameters of the current url.  In this example, the function will only set the controller name and action name with ‘control’ and ‘action’ respectively. Thus if there’s additional parameter in the url, say id, then the id and its value will be retained in the new url.
  • If your code needs to access variable(s) within a Controller,  then put your code within an override function preDispatch() instead of init(). Function init() does not allow your code to access the desired variable within the Controller.

Database

  • To order your query result, use $select->order() instead of $select->fetch($query, $order).
  • Use $db->select()->setIntegrityCheck(false) if you encounter the following error message.
    Multiple SQL statements are not allowed (SELECT ...; DELETE..;)
    $db->select()->join()
    Exception information:
    Message: Select query cannot join with another table
    

    You may refer to this site for more information.

Hope this post helps settle down your unhealthy frustration. Enjoy! :)

If you find this post helpful, appreciate if you could leave your rating below to indicate that this post is really useful and at the same time let others know about this post. Thank you friend :)

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Don't leave just yet! You may also be interested to take a quick look at my other posts.

  1. Start SOAP with Zend Framework
  2. SQL Queries Performance Findings on MySql
  3. Quick and Easy Way to Create Model Class in PHP
  4. Read Remote Content or File using Zend
  5. Start ORM with LINQ in .Net Framework

Tags: , , ,

Leave a Reply

Spam protection by WP Captcha-Free