有谁知道如何使用数据记录来实现我的sql代码

SELECT *
FROM `jadwal`
WHERE YEAR(tgl) = YEAR(NOW())
  AND MONTH(tgl) = MONTH(NOW())
  AND DAY(tgl) = DAY(NOW())


提前致谢

最佳答案

您可以按照以下步骤进行操作-

$where = array('YEAR(tgl)' => YEAR(NOW()),
               'MONTH(tgl)' => MONTH(NOW()),
               'DAY(tgl)' => DAY(NOW())
              );
$this->db->select('*');
$this->db->where($where);
$query = $this->db->get('jadwal');
$res1 = $query->result(); // as object
$res2 = $query->result_array(); // as array


尝试让我知道。

09-19 18:00