我正在尝试使用mysql函数进行多条件连接,但是codeigniter将函数放在“`”之间并且使请求失败。
$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)`
答案 0 :(得分:2)
上次加入参数允许使用&#34;`&#34;
跳过转义条件/**
* 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)
谢谢迈克尔!