我需要帮助,我是CI的新手。
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'bdate LIKE '%9/27/2015%' escape '!'}'.
SELECT SUM(amount) as score FROM paid WHERE bdate LIKE '%9/27/2015%' {escape '!'}
Filename: D:/BYCI/application/models/income.php
Line Number: 7
以下是代码
$d = date("M j Y",strtotime('today'));
$date4paid = date("n/j/o",strtotime($d));
$this->db->select('SUM(amount) as score');
$q = $this->db->get_where('paid',array('bdate' => date("n/j/o",strtotime($d))),0,0);
$row=$q->row();
return $score=$row->score;
下面的代码有效,但它给了我错误的输出。我需要获得当天的总收入。
$d = date("M j Y",strtotime('today'));
$date4paid = date("n/j/o",strtotime($d));
$this->db->select('SUM(amount) as score');
$arr = array('bdate' => $date4paid);
$q=$this->db->get('paid');
$this->db->like($arr);
$row=$q->row();
return $score=$row->score;
我已经做了几个星期的一周,但我仍然无法理解。我正在使用CI 3.0版本
谢谢。答案 0 :(得分:0)
而不是LIKE
使用WHERE
尝试使用以下查询,Where子句可以帮助您生成特定日期的数据。
$this->db->select('SUM(amount) as score');
$this->db->where('bdate',$date4paid);
$q=$this->db->get('paid')->row();