Thursday, February 24, 2011

Zend PHP Redirect from anywhere

$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $redirector->gotoUrl('/redirect/path');

 

Jquery onfocus for textfield default value

var default_value = "default data"; $('.class').focus(function() { if(this.value == default_value) { this.value = ''; } }); $(.class).blur(function() { if(this.value == '') { this.value = default_value; } });

 

Zend Render a different view script path

You can add this in any processing function.

$view = new Zend_View(); $view->addScriptPath("script/path"); $view->data = $data; // assign data to view $view->render('script_file_name'); // e.g. test.phtml

Note : if the view is not rendered then use exit at the last line of the view script file.

Tuesday, February 22, 2011

Zend mail

   $mail = new Zend_Mail ();
   $mail->setFrom('from_email_id', 'From Name');
   $mail->addTo('to_email_id', 'Recipient Name');
   $mail->setSubject('Email subject');
   $mail->setBodyText('Email content');
   $mail->send();

Getting duplicate entries and their count

For getting the duplicates you can use HAVING and GROUP BY functions in mysql


SELECT COUNT(*) AS num_entries, Email FROM subscribers GROUP BY Email HAVING num_entries > 1