【发布时间】:2011-10-30 16:53:07
【问题描述】:
我想现在在哪里完成日期,数据库表中的日期为偏移量 2 中的 JSON(例如:2011/10/30 = date now 和 Etc.),在我的尝试中输出行数为 0。怎么办?
我在表格中的列:
$today = date("Y/m/d"); // This is 2011/10/30
$query = $this->db->query("SELECT * FROM table WHERE new_date LIKE $today");
echo $query->num_rows(); // This output is "0"
【问题讨论】:
-
对不起 :))。你能帮帮我吗?
-
在数据库中,您的格式为“2011\/10\/29”,但您使用“2011/10/29”作为“$today”的值。尝试两件事:a) 在 $today 周围加上引号:"SELECT * FROM
tableWHEREnew_dateLIKE '$today'" 和 b) 将日期更改为 "2011\/10\/29" 格式并重试? -
嗨 JimBo - 在下面尝试我的答案 - 我忘记了 %% 分隔符。
标签: php json codeigniter