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

WBOY
Release: 2016-07-12 08:52:08
Original
776 people have browsed it

A summary of the usage of the database operation function $this->db->where() in the CI framework, this-db-

The examples in this article summarize the database operations in the CI framework Function $this->db->where() related usage. 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 the optional third parameter accepted by $this->db->where() is set to FALSE, CodeIgniter will not provide protection for 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 clauses generated by this function are connected using OR:

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

Copy after login

Note: or_where() used to be called orwhere(), which is obsolete.

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

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

$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 statement, and connect it 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 statement, and connect it 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 statement, and connect it 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

Readers who are interested in more CodeIgniter related content can check out the special topics of this site: "codeigniter introductory tutorial", "CI (CodeIgniter) framework advanced tutorial", "php excellent development framework summary", "ThinkPHP introductory tutorial", "Summary of Common Methods in ThinkPHP", "Introduction Tutorial on Zend FrameWork Framework", "Introduction Tutorial on PHP Object-Oriented Programming", "Introduction Tutorial on PHP MySQL Database Operation" and "Summary of Common PHP Database Operation Skills"

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1127874.htmlTechArticleSummary of related usage of database operation function $this-db-where() in CI framework, this-db- Example of this article Summarizes the usage of the database operation function $this-db-where() in the CI framework. Share it with everyone...
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template