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

How to get HTTP REFERER value in Zend Framework

You can get that directly in Controller using the below code
     $requestUri    =    $this->getRequest()->getServer('HTTP_REFERER');
 If you want to get that outside of Controller you can use the Zend Front Contorller class
 $requestUri    =    Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();

How to get method name in controller while we try Zend JSON Service call

 You can use the below code in your controller to get the method name while you try jQuery.Zend.Jsonrpc service call

if($_SERVER['REQUEST_METHOD']    ==    'POST') {
            $data     =    json_decode(urldecode($this->getRequest()->getRawBody()));
            echo $data->method;
}

jQuery.Zend.jsonrpc returns error 'not a function' with cross domain request

There is a chance to retun 'not a function' error in console while we try the remote url.
 You can fix that with the following changes

  1. Use the latest jquery file
  2. Remove the 'content-type' attribute from jquery.zend.jsonrpc.js
  3. Add the property 'crossDomain: true' in jquery.zend.jsonrpc.js with ajax request
  4. Set the header("Access-Control-Allow-Origin: *") in your server script.
 
   I have followed the below url and updated the file with above condition then it works fine.
   http://sourcecodebean.com/archives/creating-a-json-rpc-service-using-zend-json-server/422

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