Is it possible to specify "USE INDEX" or "FORCE INDEX" in CodeIgniter, other than using

除了使用之外,是否可以在CodeIgniter中指定“使用索引”或“强制索引”

$this->db->query()

What I mean is if it's possible to insert "FORCE INDEX" somewhere in one of ActiveRecord's methods.

我的意思是,如果可以在ActiveRecord的某个方法中插入“FORCE INDEX”。

1 个解决方案

#1


4

You can use the from() active record method to add this in queries like this:

您可以使用from()活动记录方法在如下查询中添加:

$this->db->like('name', 'user', 'after')->from('users use index (name)')->get();

produces sql query like this:

生成如下sql查询:

 SELECT * FROM (`users` use index (name)) WHERE  `name`  LIKE 'user%'

One caveat is that the from() method tries to find identifiers and multiple tables so adding one or more , to it's input is most likely to end up as an SQL syntax error.

需要注意的一点是,from()方法试图查找标识符和多个表,因此向其输入添加一个或多个表很可能会导致SQL语法错误。

更多相关文章

  1. php使用mysql数据库时中文不显示或显示异常解决方法
  2. 保存在Java桌面应用程序应用程序和网站上使用的个人用户设置的最
  3. MySQL 存储过程查询远程数据库的方法
  4. 深入理解Mysql索引底层数据结构与算法
  5. 为什么MySQL查询优化器会选择聚集主索引上的二级索引?
  6. 有没有更好的方法来编写这个MySQL查询?
  7. 计算机管理没有mysql服务项的解决方法
  8. Mysql索引基础原理
  9. mysql 批量更新与批量更新多条记录的不同值实现方法

随机推荐

  1. Android(安卓)在oncreate() 方法中调用 f
  2. Android实现九宫格 主界面应用列表效果
  3. android的xml解析
  4. android之inputType属性
  5. Android SDK中 tools 目录下的工具介绍
  6. ubuntu下第一个Jni例子
  7. 在Android中如何使用全局变量--Applicati
  8. Android(安卓)Activity生命周期管理 .
  9. [Android] 设置控件是否可见
  10. android CTS测试全pass攻略