如何根据 PHP 中的会话数据将用户重定向到不同的页面?
How can I redirect users to different pages based on session data in PHP?
如何在 codeigniter 中执行以下查询后获取最近十天的日期
public function get_data() {
$this->db->select('*');`enter code here`
$this->db->select_sum('total_sale');
$this->db->where('store_date BETWEEN CURDATE() - INTERVAL 7 DAY AND CURDATE()');
$query = $this->db->get('one_month_report');
if ($query->num_rows() > 0) {
return $query->result();
} else {
return FALSE;
}
}
试试这个
public function get_data()
{
$query = $this->db->query("SELECT *, SUM(cast(REPLACE(total_sale, ',', '') as decimal(8,2)))
FROM one_month_report
WHERE store_date BETWEEN CURDATE() AND DATE(NOW()) - INTERVAL 7 DAY");
$result= $query->result_array();
if (empty($result)) {
echo "Empty result";
} else {
return $result;
}
}
Make sure CURDATE()
is returning date
请试试这个:
$this->db->select('*');
$this->db->select_sum('total_sale');
$this->db->where('store_date BETWEEN DATE_SUB(NOW(), INTERVAL 7 DAY) AND NOW()');
$query = $this->db->get('one_month_report');
如果您的数据库将这些值存储为 DATETIME 或 TIMESTAMP,这应该有效。
$start_date = date("Y-m-d 00:00:00", strtotime("-1 week"));
$end_date = date("Y-m-d 59:59:59");
$this->db->where("store_date >= '" . $start_date . "' AND store_date <= '" . $end_date . "'");
这对我有用..
$this->db->from('backbonedb');
$this->db->where('status', $status);
$this->db->where('date <=', date('Y-m-d'));
$this->db->where('date >=', date('Y-m-d', strtotime('-7 days')));
$this->db->order_by("id", "DESC");
$query = $this->db->get();
如何在 codeigniter 中执行以下查询后获取最近十天的日期
public function get_data() {
$this->db->select('*');`enter code here`
$this->db->select_sum('total_sale');
$this->db->where('store_date BETWEEN CURDATE() - INTERVAL 7 DAY AND CURDATE()');
$query = $this->db->get('one_month_report');
if ($query->num_rows() > 0) {
return $query->result();
} else {
return FALSE;
}
}
试试这个
public function get_data()
{
$query = $this->db->query("SELECT *, SUM(cast(REPLACE(total_sale, ',', '') as decimal(8,2)))
FROM one_month_report
WHERE store_date BETWEEN CURDATE() AND DATE(NOW()) - INTERVAL 7 DAY");
$result= $query->result_array();
if (empty($result)) {
echo "Empty result";
} else {
return $result;
}
}
Make sure
CURDATE()
is returning date
请试试这个:
$this->db->select('*');
$this->db->select_sum('total_sale');
$this->db->where('store_date BETWEEN DATE_SUB(NOW(), INTERVAL 7 DAY) AND NOW()');
$query = $this->db->get('one_month_report');
如果您的数据库将这些值存储为 DATETIME 或 TIMESTAMP,这应该有效。
$start_date = date("Y-m-d 00:00:00", strtotime("-1 week"));
$end_date = date("Y-m-d 59:59:59");
$this->db->where("store_date >= '" . $start_date . "' AND store_date <= '" . $end_date . "'");
这对我有用..
$this->db->from('backbonedb');
$this->db->where('status', $status);
$this->db->where('date <=', date('Y-m-d'));
$this->db->where('date >=', date('Y-m-d', strtotime('-7 days')));
$this->db->order_by("id", "DESC");
$query = $this->db->get();