如何在使用活动记录时忽略codeigniter中的反引号?我需要按个案排序 [英] how do i ignore the backticks in codeigniter when using active records? i need to order by cases

查看:148
本文介绍了如何在使用活动记录时忽略codeigniter中的反引号?我需要按个案排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在使用活动记录时忽略codeigniter中的反引号?我需要按个案排序

 当roll_number为空时,否则为1 else 0 end,
  

ORDER BY`case`当roll_number为null然后1 else 0 end

这给我一个错误。请帮助

解决方案

这可能有点老,但对于正在寻找答案的人可以添加



$ this-> db-> _protect_identifiers = false;



请注意,这会移除此查询


上的所有反引号

how do i ignore the backticks in codeigniter when using active records? i need to order by cases

case when roll_number is null then 1 else 0 end,

which code igniter makes it as

ORDER BY `case` when roll_number is null then 1 else 0 end

which gives me an error. Please help

解决方案

This could be a little old, but for someone who is looking for an answers you could add

$this->db->_protect_identifiers=false;

be aware that this will remove all backticks on this query

这篇关于如何在使用活动记录时忽略codeigniter中的反引号?我需要按个案排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆