Php 获取所有值,而不是获取搜索结果
在这里,我想根据我想给出的日期得到结果,但返回整个结果 数据库看起来像这样Php 获取所有值,而不是获取搜索结果,php,codeigniter,datepicker,Php,Codeigniter,Datepicker,在这里,我想根据我想给出的日期得到结果,但返回整个结果 数据库看起来像这样 customer_account_id customer_id date code 11 55 01-01-2017 ALI HAJI 12 55 02-01-2017 ALI HAJI
customer_account_id customer_id date code
11 55 01-01-2017 ALI HAJI
12 55 02-01-2017 ALI HAJI
13 55 03-01-2017 ALI HAJI
125 65 01-02-2017 SHARFU
126 55 02-02-2017 ALI HAJI
127 55 03-02-2017 ALI HAJI
128 55 31-01-2017 ALI HAJI
public function report()
{
$from=$this->input->post('from_date');
$to = $this->input->post('to_date');
$from1= date('d-m-Y', strtotime($from));
$to1= date('d-m-Y', strtotime($to));
$data['result']= $this->Account_model->get_report($from1,$to1)->result();
$this->load->view('report_payment_details',$data);
}
public function get_report($from1,$to1)
{
$this->db->order_by('customer_account_id','desc');
$this->db->where('date >=', $from1);
$this->db->where('date <=', $to1);
return $this->db->get('customer_accounts');
}
控制器看起来像这样
customer_account_id customer_id date code
11 55 01-01-2017 ALI HAJI
12 55 02-01-2017 ALI HAJI
13 55 03-01-2017 ALI HAJI
125 65 01-02-2017 SHARFU
126 55 02-02-2017 ALI HAJI
127 55 03-02-2017 ALI HAJI
128 55 31-01-2017 ALI HAJI
public function report()
{
$from=$this->input->post('from_date');
$to = $this->input->post('to_date');
$from1= date('d-m-Y', strtotime($from));
$to1= date('d-m-Y', strtotime($to));
$data['result']= $this->Account_model->get_report($from1,$to1)->result();
$this->load->view('report_payment_details',$data);
}
public function get_report($from1,$to1)
{
$this->db->order_by('customer_account_id','desc');
$this->db->where('date >=', $from1);
$this->db->where('date <=', $to1);
return $this->db->get('customer_accounts');
}
我的模型看起来像这样
customer_account_id customer_id date code
11 55 01-01-2017 ALI HAJI
12 55 02-01-2017 ALI HAJI
13 55 03-01-2017 ALI HAJI
125 65 01-02-2017 SHARFU
126 55 02-02-2017 ALI HAJI
127 55 03-02-2017 ALI HAJI
128 55 31-01-2017 ALI HAJI
public function report()
{
$from=$this->input->post('from_date');
$to = $this->input->post('to_date');
$from1= date('d-m-Y', strtotime($from));
$to1= date('d-m-Y', strtotime($to));
$data['result']= $this->Account_model->get_report($from1,$to1)->result();
$this->load->view('report_payment_details',$data);
}
public function get_report($from1,$to1)
{
$this->db->order_by('customer_account_id','desc');
$this->db->where('date >=', $from1);
$this->db->where('date <=', $to1);
return $this->db->get('customer_accounts');
}
公共函数get_报告($1,$to1)
{
$this->db->order_by('customer_account_id','desc');
$this->db->where('date>=',$from1);
$this->db->where('date首先,列的数据类型应为date
。请尝试下面的代码
$this->db->order_by('customer_account_id','desc');
$this->db->where('date >=', $from1);
$this->db->where('date <=', $to1);
$result = $this->db->get('customer_accounts');
echo $this->db->last_query();
print_r($result);
$this->db->order\u by('customer\u account\u id','desc');
$this->db->where('date>=',$from1);
$this->db->where('date试试这个,先生
$this->db->order_by('customer_account_id DESC');
$this->db->limit('1');
公共函数get_报告($1,$to1)
{
$this->db->order_by('customer_account_id','desc');
$this->db->where('date>=',$from1);
$this->db->where('date尝试使用$this->db->last_query()打印查询)在整个MySQL控制台上执行打印查询是否有任何想法,问题是前两个值是从日期考虑的,例如,如果我考虑“代码>01-01-2017 < /COD>”,这里只有01考虑和剩余。检查值为$1和$to1,它应该是B。e以yyyy mm DDI的形式如果您得到结果,那么它应该打印正在执行的查询从customer
中选择*WHEREcategory\u id
=2我得到了这样的结果怎么可能?您正在执行customer\u accounts
的查询,并且customer
表正在使用将粘贴我使用的代码请参见了解结果如何?