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);

How to check multi-option Zend Form array values in View

We can get the Multi-option values set in Zend Form  and to compare the values in the view using the following function.
  
   Ex: $multiValues    =    $this->form->getElement('all_roles')->getMultiOptions();
        In the 'all_roles' is the form elememnt name in the Form/

How to add 'default' attribute with url parameter

In the url function first we define the controller, action and parameters. Then we need to add the 'default' attribute or else the url is formed with the existing url in the browser.
 $this->url(array('controller'=>'events','action'=>'view','id'=>1),'default',true);