用户表
id stamp_created email_address
1 2013-03-06 22:00:01 test+1@gmail.com
2 2013-03-20 22:00:08 test+2@gmail.com
3 2013-03-27 22:00:17 test+3@gmail.com
4 2013-04-01 22:00:27 test+4@gmail.com
我有这个查询
SELECT
`user`.*
FROM
`user`
WHERE
`user`.`email_address` IS NOT NULL
AND (`user`.`stamp_created` BETWEEN '2013-04-01 00:00:00' AND '2013-04-01 23:59:59')
在phpmyadmin中运行查询时,我得到了正确的结果
4 2013-04-01 22:00:27 test+4@gmail.com
但是当我通过
运行查询时$sql = "SELECT
`user`.*
FROM
`user`
WHERE
`user`.`email_address` IS NOT NULL
AND (`user`.`stamp_created` BETWEEN '2013-04-01 00:00:00' AND '2013-04-01 23:59:59')
";
$this->db->query($sql)->result_array();
我得到一个空数组。
知道为什么会这样吗?
P.S。已经确认CI和phpmyadmin正在使用相同的数据库,因此不是问题。
答案 0 :(得分:0)
如果你尝试
怎么办?$query = $this->db->sql('yourquery');
if($query->num_rows() > 0){
foreach($query->result() as $row){
$retdat[] = array(
'test1' => $row->stamp_created
);
}
print_r($retdat);
}