Code Igniter SQL 注入和查询结构(具有相同列名的动态 where 子句)

Code Igniter SQL Injection and query structure (dynamic where clause with same column name)

我正在尝试确保我的代码点火器查询不会受到 sql 注入的影响,但我真的找不到说明这一点或解释我使用的这些参数是否为 [=20] 的示例=].

$inputArray = [1,2,3,4,5];
$this->db_name->select('a_column');
$this->db_name->from('a_table');
foreach ($inputArray as $item) {
    $this->db_name->or_where('id',$item);
}

$query = $this->db_name->get();

最重要的是,我正在检查的所有项目是否作为输入数组 bound/escaped 中的匹配 ID 来防止 SQL 注入?如果没有,我应该如何在这样的查询中构造它?

我真的不在乎我是如何构建这个查询的,如果有任何指导,我们将不胜感激。事实上,我一点也不喜欢它,但我需要确保我正在使用带有代码启动器的查询构建,这样无论出于何种原因我没有使用它,它都可以轻松切换到不同的数据库系统我现在正在使用的那个(例如 mysql 到 oracle)——我也意识到,如果我只是将它与常规 SQL 放在一起,那么简单的 where 子句可能永远不会不同并且是通用的但是当出现其他情况并且数据库系统和语法之间可能更复杂或不同时,我正在尝试学习 CI 的最佳实践。

非常感谢任何帮助!谢谢

是的,它受到保护。来自 CodeIgniter QueryBuilder documentation

Beyond simplicity, a major benefit to using the Query Builder features is that it allows you to create database independent applications, since the query syntax is generated by each database adapter. It also allows for safer queries, since the values are escaped automatically by the system.