How to use MySQL 'RAND()' with limit in with Zend Select Query

  We need to use new Zend_Db_Expr('RAND()') with select query
  Ex: $selectQry    =    $this->util->db->select()->from(array('P'=>$this->_name),array('package_id','name','day_duration','night_duration','price','discount_price'))
                                                    ->order(new Zend_Db_Expr('RAND()'))
                                                    ->limit(2);

Html email using Zend Framework

Create a template in the view /views/scripts/emails/package.phtml
html
body
 echo $this->packageType;
echo $this->details; 
/html

Then in the controller, from which you need to send this use the below code

// create zend view object
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/emails/');

// assign the view variables here
$html->assign('packageType', 'Luxure');
$html->assign('details', 'Package inclusions');

// create mail object with utf-8 encoding
$mail = new Zend_Mail('utf-8');

// render view
$bodyText = $html->render('package.phtml');

//Set emaill
$mail->addTo('shaijudavis@gmail.com');
$mail->setSubject('Welcome to Limespace.de');
$mail->setFrom('info@elegantkerala.com','Elegant Kerala');
$mail->setBodyHtml($bodyText);
$mail->send();

How to use MySQL MATCH AGAIST in Zend Framework Query

   We can use MATCH AGAINST with zend select where clause.
   Ex:
  $selectQry    =    $this->db->select()->from(array('D'=>$this->_name))
                                                     ->joinLeft(array('C'=>TBL_CATEGORIES),
                                                         'C.category_id = D.category_id',array('category_id'))
                                                    ->where('D.is_deleted = ?', 0)
                                                    ->where('MATCH(C.name) AGAINST (?)', $txt)
                                                    ->orWhere('MATCH(D.name,D.summary,D.description) AGAINST (?)', $txt)
                                                    ->group('D.destination_id');

How to get request path info in the controller?

To get the request pathinfo use the function $this->_request->getPathInfo() in the controller

How to disable the In Array validator in Zend Form?

When we use multiple select or checkbox option, there is default validator so that the value should not be empty. We can bypass it using the function setRegisterInArrayValidator
 
   Ex: $selCategories = new Zend_Form_Element_MultiCheckbox('categories', array(
                        'multiOptions' => $categories));
         $selCategories->setRegisterInArrayValidator(false);

How to save Log in a text file using Zend Framework

We can do that using Zend Log & Zend Log Writer Stream classes.
Ex:
 $logText        =    'TEST TO LOG THE STRING IN TEXT FILE';
 $stream        =    fopen('/var/www/log/path/filename.txt', 'a');
 if( $stream ){
   $writer        =    new Zend_Log_Writer_Stream($stream);
   $logger        =    new Zend_Log($writer);
   $logger->log($logText,Zend_Log::INFO);
  }

How to redirect in Zend Framework without using standard redirect function

If you want to use Zend redirect without using standard redirect function from controller, you can use the below code in any of the plugin or function.
 $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
  $redirector->gotoUrl('/profile/change-password/')->redirectAndExit();