简体   繁体   English

启用 Codeigniter 查询生成器

[英]Enable Codeigniter Query Builder

I am using CodeIgniter v3.1.4 and I'd like to take advantage of Query Builder.我正在使用 CodeIgniter v3.1.4,我想利用查询生成器。

As far as I can tell, all I need to do is set $query_builder to TRUE in config/database.php , which I have done.据我所知,我需要做的就是在config/database.php中将$query_builder设置$query_builder TRUE,我已经完成了。 But, when I try to use the class, I get the following error:但是,当我尝试使用该类时,出现以下错误:

Message: Call to undefined method CI_DB_odbc_driver::where()消息:调用未定义的方法 CI_DB_odbc_driver::where()

I am using Wiredesignz' HMVC implementation, which overrides (among other things) the Loader class, through which the $query_builder variable is transferred.我正在使用 Wiredesignz 的 HMVC 实现,它覆盖(除其他外)Loader 类,通过它传输$query_builder变量。

I'm a little surprised that this feature can be toggled on/off via a global variable, rather than directly through db config data.我有点惊讶这个功能可以通过全局变量打开/关闭,而不是直接通过 db 配置数据。 Nevertheless, I have tried toggling it on and off without success.尽管如此,我尝试打开和关闭它但没有成功。

Not sure that it's relevant but I'm using the ODBC driver and my query looks like this:不确定它是否相关,但我使用的是 ODBC 驱动程序,我的查询如下所示:

$this->db->where('userid', $userid)->set($data);

Any idea what I am missing?知道我缺少什么吗?

I've stumbled upon the same issue today when trying to transition to odbc.我今天在尝试过渡到 odbc 时偶然发现了同样的问题。

In CI 3.1.0 they dropped support for ODBC on their querybuilder (which -in my opinion- defeats the reasons for using the QB in the first place)在 CI 3.1.0 中,他们在查询构建器上放弃了对 ODBC 的支持(在我看来,这首先否定了使用 QB 的原因)

The reason is that their implementation caused a SQL injection vulnerability;原因是他们的实现导致了SQL注入漏洞; however they seem to have no plans on fixing it;然而他们似乎没有修复它的计划; but rather disable QB entirely for odbc, locking you in.而是完全禁用 odbc 的 QB,将您锁定。

source: https://forum.codeigniter.com/thread-65803.html来源: https : //forum.codeigniter.com/thread-65803.html

"upgrade notes": http://www.codeigniter.com/user_guide/installation/upgrade_310.html “升级说明”: http : //www.codeigniter.com/user_guide/installation/upgrade_310.html

Github issue stating unlikeliness of a fix: https://github.com/bcit-ci/CodeIgniter/pull/5197 Github 问题说明修复的可能性: https : //github.com/bcit-ci/CodeIgniter/pull/5197

Check for the following option in application/config/database.php:检查 application/config/database.php 中的以下选项:

$query_builder = TRUE;

$query_builder should be true if you want to use query builder classes of CI如果您想使用 CI 的查询构建器类,则$query_builder应该为true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM