Home Web Front-end JS Tutorial CI框架中数据库操作函数$this->db->where()相关用法总结_php实例

CI框架中数据库操作函数$this->db->where()相关用法总结_php实例

Jun 07, 2016 pm 05:07 PM
ci framework function Database operations

本文实例总结了CI框架中数据库操作函数$this->db->where()相关用法。分享给大家供大家参考,具体如下:

CI 框架数据库操作函数 this->db->where() 的使用

1) $this->db->where('MATCH (field) AGAINST ("value")', NULL, FALSE)

如果把$this->db->where() 接受可选的第三个参数设置为 FALSE, CodeIgniter 将不会为那些包含反勾号的字段名或表名提供保护。

2) $this->db->or_where()

本函数与上面的那个几乎完全相同,唯一的区别是本函数生成的子句是用 OR 来连接的:

$this->db->where('name !=', $name);
$this->db->or_where('id >', $id);
// 生成: WHERE name != 'Joe' OR id > 50

Copy after login

说明: or_where() 以前被叫作 orwhere(), 后者已经过时。

3) $this->db->where_in();

生成一段 WHERE field IN ('item', 'item') 查询语句,如果合适的话,用 AND 连接起来。

$names = array('Frank', 'Todd', 'James');
$this->db->where_in('username', $names);
// 生成: WHERE username IN ('Frank', 'Todd', 'James')

Copy after login

4)$this->db->or_where_in();

生成一段 WHERE field IN ('item', 'item') 查询语句,如果合适的话,用 OR 连接起来。

$names = array('Frank', 'Todd', 'James');
$this->db->or_where_in('username', $names);
// 生成: OR username IN ('Frank', 'Todd', 'James')

Copy after login

5)$this->db->where_not_in();

生成一段 WHERE field NOT IN ('item', 'item') 查询语句,如果合适的话,用 AND 连接起来。

$names = array('Frank', 'Todd', 'James');
$this->db->where_not_in('username', $names);
// 生成: WHERE username NOT IN ('Frank', 'Todd', 'James')

Copy after login

6)$this->db->or_where_not_in();

生成一段 WHERE field NOT IN ('item', 'item') 查询语句,如果合适的话,用 OR 连接起来。

$names = array('Frank', 'Todd', 'James');
$this->db->or_where_not_in('username', $names);
// 生成: OR username NOT IN ('Frank', 'Todd', 'James')

Copy after login

更多关于CodeIgniter相关内容感兴趣的读者可查看本站专题:《codeigniter入门教程》、《CI(CodeIgniter)框架进阶教程》、《php优秀开发框架总结》、《ThinkPHP入门教程》、《ThinkPHP常用方法总结》、《Zend FrameWork框架入门教程》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于CodeIgniter框架的PHP程序设计有所帮助。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Tips for dynamically creating new functions in golang functions Tips for dynamically creating new functions in golang functions Apr 25, 2024 pm 02:39 PM

Tips for dynamically creating new functions in golang functions

Considerations for parameter order in C++ function naming Considerations for parameter order in C++ function naming Apr 24, 2024 pm 04:21 PM

Considerations for parameter order in C++ function naming

How to write efficient and maintainable functions in Java? How to write efficient and maintainable functions in Java? Apr 24, 2024 am 11:33 AM

How to write efficient and maintainable functions in Java?

Comparison of the advantages and disadvantages of C++ function default parameters and variable parameters Comparison of the advantages and disadvantages of C++ function default parameters and variable parameters Apr 21, 2024 am 10:21 AM

Comparison of the advantages and disadvantages of C++ function default parameters and variable parameters

Complete collection of excel function formulas Complete collection of excel function formulas May 07, 2024 pm 12:04 PM

Complete collection of excel function formulas

What are the benefits of C++ functions returning reference types? What are the benefits of C++ functions returning reference types? Apr 20, 2024 pm 09:12 PM

What are the benefits of C++ functions returning reference types?

What is the difference between custom PHP functions and predefined functions? What is the difference between custom PHP functions and predefined functions? Apr 22, 2024 pm 02:21 PM

What is the difference between custom PHP functions and predefined functions?

C++ Function Exception Advanced: Customized Error Handling C++ Function Exception Advanced: Customized Error Handling May 01, 2024 pm 06:39 PM

C++ Function Exception Advanced: Customized Error Handling

See all articles