How to Reset all the values in Zend Form After Submit

   We can use the reset function to clear all the values in Zend Form
   Ex: $formObt->reset();

How to change Zend DB fetchAll() result Array to Object


 For that we need to use the setFetchMode function.

  Ex:  $stmt = $db->query('SELECT * FROM user');
       $stmt->setFetchMode(Zend_Db::FETCH_OBJ);
        $objs = $stmt->fetchAll();

How to to check mail delivery in Zend Framework

              $mail = new Zend_Mail();
                $mail->setBodyText('This is my test message');
                $mail->setFrom('info@cochinhub.com', 'From Name');
                $mail->addTo('sales@cochinhub.com', 'To Name');
                $mail->setSubject('Add subject here');
                try {
                    $mail->send();
                }catch (Zend_Exception $e){
                    echo $e->getMessage();
                }

How to connect MYSQL Database using Zend Framework

   require_once 'Zend/Db.php';
    $dbConnect = Zend_Db::factory("MYSQLI",
                    array(
                        "host" => "localhost",
                        "dbname" => "my_db",
                        "username" => "dbUserName",
                        "password" => "dbPassword")
    );

MysQL UNION in Zend Framework


$selectQry1 = $this->db->select()->from(array('F'=>$tableName))
        ->join(array('FA'=>$tableName2),
        'FA.form_id=F.form_id',
        array('association_id','association_type', 'object_id'))
        ->where('FA.association_type = ?','user')
        ->where('FA.object_id = ?',mysql_escape_string($this->_userId));   
$selectQry2 = $this->db->select()->from(array('F'=>$tableName))
        ->join(array('FA'=>$tableName2),
        'FA.form_id=F.form_id',
        array('association_id','association_type', 'object_id'))
        ->where('FA.association_type = ?','group')
        ->where('FA.object_id IN ( ? )',$groups);   
$selectQry = $this->db->select()->union(array($selectQry1, $selectQry2), Zend_Db_Select::SQL_UNION_ALL)
         ->group('form_id');

How to get Url parameters in Zend Model, Form or any other Classes

ex: url - http://www.example.com/token/TK_15ada12sada1245ad
 
  Then you can get the token value using the following function.
 
  $token =    Zend_Controller_Front::getInstance()->getRequest()->getParam('token');
 

 

How to remove 'requied' validator from Zend_Form

We can use setRequired() function for that.It's useful when you have to use element in different and one need required field and another is not mandatory
  Ex:
    $element = Zend_Form_Element_Text('phoneNumber');
    $element->setRequired(false);