簡體   English   中英

使用Codeigniter從mysql數據庫中獲取記錄的問題

[英]Issue in fetching records from mysql database using codeigniter

我在php中使用codeigniter框架。我有一個帶有日期和時間的時間戳的發票表。我想在日期之間獲取記錄。

例如:我已經嘗試了以下內容,但沒有用

    $data['sdate']         = $this->input->post('sdate');
    $data['edate']              = $this->input->post('edate');
    $this->db->select('invoice_id')
             ->from('invoice')
             ->where('DATE( FROM_UNIXTIME( creation_timestamp ) ) >= ',$data[sdate])
             ->where('DATE( FROM_UNIXTIME( creation_timestamp ) ) <=',$data[edate]);
     $page_data['invoice']=$this->db->get()->result_array(); 

但這是行不通的。 有誰知道如何解決這一問題? 提前致謝。

嘗試這個:

$data['sdate'] = strtotime($this->input->post('sdate'));
$data['edate'] = strtotime($this->input->post('edate'));
$this->db->select('invoice_id')
         ->from('invoice')
         ->where('creation_timestamp >= ',$data[sdate])
         ->where('creation_timestamp <= ',$data[edate]);
 $page_data['invoice']=$this->db->get()->result_array();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM