2012-02-16 35 views
0

我想在zend註冊表中存儲mysql查詢,因爲我有一個操作,那是通過ajax調用,但以兩種不同的方式。如何在zend註冊表中存儲查詢(ZF)

1 =發生java腳本事件時。那就是

$("#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; 
    } 

上面的代碼從元素中取值,調用我的動作並根據查詢進行查詢。 這項工作很好

2 = when(zend paginator in my action)pagination links clicks。 的問題是在這裏當我點擊任何分頁所以肯定它的調用同樣的動作,並通過Ajax調用所以它給人的錯誤,我改變了我這樣的代碼

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

首先是其沒有得到我中國率先它的值將不會到第一個IF語句,所以我在我的存儲我的查詢在註冊表中,當分頁鏈接點擊,所以不會設置我的4個變量和第一個IF語句將執行,所以我會得到我存儲在註冊表中。 但在這種情況下,它給了我這是

Message: No entry is registered for key 'select' 

任何1,請幫助我

回答

0

記住Zend_Registry保持其值只有等到當前請求已經完成了錯誤。如果您在一個請求中設置了該值,並希望在另一個請求中檢索該值,則應該使用Zend_Session代替。

希望幫助,

+0

我想它現在但經過一段時間的工作方式可能會到期,所以它沒有做。是有辦法,使之持續性? – 2012-02-17 08:11:13

+0

您可能會使用Zend_Session的rememberMe()方法來稍微過期。更多詳細信息,請訪問:http://framework.zend.com/manual/en/zend.session.global_session_management.html – dinopmi 2012-02-17 10:43:04

相關問題