I want to store mysql query in zend registry because i have one action and that is calling through ajax but in 2 different ways.
1= when java script event occur. that is
$("#show_history_call_logs").click(function(){
var pass = true;
var start_date = $("#start_date").val();
var end_date = $("#end_date").val();
var page_to_get = $('input[name=hidden]').val();
//some validation
if(pass == true){
var href= "http://localhost/abc/xyz/index.php/login/"+page_to_get+"/";
var data ='start_date=' + start_date + '&end_date=' + end_date + '&option_call_log=' + option_call_log + '&option_call_log_asc_desc=' + option_call_log_asc_desc;
$.ajax({ type: "GET",
url: href,
data: data,
success: function(response){
$('#paged-data-container').html(response);
}
});
return false;
}
the above code takes values from elements call my action and make query according. this work fine
2 = when (zend paginator in my action )pagination links clicks. the problem is here when i click any pagination so certainly its calling the same action and its not getting the values i passsed it through ajax call so its giving error for that i changed my code like this
$registry = Zend_Registry::getInstance();
$start_date = $this->_getParam('start_date');
$end_date = $this->_getParam('end_date');
$option_call_log = $this->_getParam('option_call_log');
$option_call_log_asc_desc = $this->_getParam('option_call_log_asc_desc');
if(empty($start_date) && empty($end_date) && empty($option_call_log) && empty($option_call_log_asc_desc)){
//$select = $registry->get('select');
$select = Zend_Registry::get('select');
}
else{
if(empty($end_date) || $end_date == ""){
$select = $DB->select()
->from('CALL_LOG', array('caller_name','call_number','call_start_time','call_duration','call_direction'))
->where('phone_service_id = ?', $phone_service_id)
->where("date_created >= ?", $start_date_formatted)
->order("".$option_call_log." ".$option_call_log_asc_desc);
Zend_Registry::set('select',$select);
}
else{
$select = $DB->select()
->from('CALL_LOG', array('caller_name','call_number','call_start_time','call_duration','call_direction'))
->where('phone_service_id = ?', $phone_service_id)
->where("date_created >= ?", $start_date_formatted)
->where("date_created <= ?", $end_date_formatted)
->order("".$option_call_log." ".$option_call_log_asc_desc);
Zend_Registry::set('select',$select);
}
}
firstly it will not come to to first IF statement so there i am storing my query in registry and when pagination links click so there will not set my 4 variables anf first IF statement will execuated so i ll get what i stored in registry. but in that case its giving me the error which is
Message: No entry is registered for key 'select'
any 1 please help me
Remember that Zend_Registry
keeps its values only until the current request has finished. If you set the value in one request and want to retrieve it in another one, you should use Zend_Session
instead.
Hope that helps,