php - Codeigniter 中 AND 的事件记录

标签 php mysql codeigniter

我如何在 codeigniter 的事件记录中写入此查询。

 SELECT * FROM `post_ads` WHERE `dates` >= '2014-09-20' AND `dates` <= '2014-09-22' ORDER BY `dates` ASC

我试过这段代码,但给出了一个空数组。

 $where = "DATE(dates) BETWEEN '2014-09-20' AND '2014-09-22'";
    $query = $this->db->where($where)->get('post_ads');
    return $query->result();

最佳答案

像这样重复两次:

$this->db->select();
$this->db->from('post_ads');
$this->db->where('dates','2014-09-20');
$this->db->where('dates','2014-09-22');
$this->db->order_by('dates');

关于php - Codeigniter 中 AND 的事件记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26137829/

相关文章:

php - 连接错误MySQL

php - 如何删除错误 phpMyAdmin #1932

php - 如果提交后已经过了一个小时则更新记录

php - 无法使用password_verify验证密码

MySQL 查询获取随机问题

mysql - Codeigniter 随机行 mysql 错误 - 类 CI_DB_mysqli_result 的对象无法转换为字符串

php - IIS 7.5 PHP 故障 "The FastCGI process exited unexpectedly"

php - 当您可以用 <<< 和结束分隔符填充字符串时,这叫做什么?

javascript - Twitter 和 Google Plus 的纯 Javascript API

python - 使用右连接和 WHERE IN 子句