Home php教程 php手册 Summary of related usage of database operation function $this->db->where() in CI framework

Summary of related usage of database operation function $this->db->where() in CI framework

Dec 27, 2016 pm 01:20 PM

The examples in this article summarize the related usage of the database operation function $this->db->where() in the CI framework. Share it with everyone for your reference, the details are as follows:

Usage of CI framework database operation function this->db->where()

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

If $this->db->where() accepts the optional third parameter, set it to FALSE, CodeIgniter will not protect field or table names that contain backticks.

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

This function is almost identical to the one above. The only difference is that the clause generated by this function uses OR. Connected:

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

Description: or_where() was previously called orwhere(), which is obsolete.

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

Generate a WHERE field IN ('item', 'item') query statement, and use AND if appropriate connect them.

$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();

Generate a WHERE field IN ('item', 'item') query statements, concatenated with OR if appropriate.

$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();

Generate a WHERE field NOT IN ('item' , 'item') query statements, connected with AND if appropriate.

$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();

Generate a WHERE field NOT IN ('item' , 'item') query statements, connected with OR if appropriate.

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

I hope this article will be helpful to everyone’s PHP program design based on the CodeIgniter framework.

For more related usage summary of the database operation function $this->db->where() in the CI framework, please pay attention to the PHP Chinese website!

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 AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

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)