如何避免在代码点火器中多个条件连接时“'”


How to avoid "`" when multiple conditional join in codeigniter?

我正在尝试使用 mysql 函数进行多条件连接,但代码点火器将函数放在"'"之间并失败请求。

$this->db
          ->join(
            'contribution_contributions t2',
            $this->db->dbprefix($this->_table).'.id = t2.contact_id  AND `t2`.`created` >= NOW() - INTERVAL 5 DAY AND `t2`.`created` < (NOW() +
                    INTERVAL 5 DAY',
            'inner'
          );

查询

INNER JOIN `default_contribution_contributions` `t2` ON `default_contribution_contacts`.`id` = `t2`.`contact_id` AND `NOW`() - `INTERVAL 5` `DAY` AND `NOW`() + `INTERVAL 5` `DAY)`

字符串t2 .created消失,两个条件都放在"'"之间

`NOW`() - `INTERVAL 5` `DAY` AND `NOW`() + `INTERVAL 5` `DAY)`

最后一个连接参数允许跳过带有 "'" 的转义条件

/**
 * Join
 *
 * Generates the JOIN portion of the query
 *
 * @param   string
 * @param   string  the join condition
 * @param   string  the type of join
 * @param   string  whether not to try to escape identifiers
 * @return  object
 */
public function join($table, $cond, $type = '', $escape = NULL)

谢谢迈克尔!