$this->db->where () Related usage summary of database operation function in CI frame _php example

Source: Internet
Author: User
Tags codeigniter zend framework

This paper summarizes the related usage of database operation function $this->db->where () in CI framework. Share to everyone for your reference, specific as follows:

The use of CI Framework database operation function This->db->where ()

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

If the $this->db->where () accepts the optional third argument set to FALSE, CodeIgniter will not provide protection for the field or table names that contain the counter tick number.

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

This function is almost identical to the one above, and the only difference is that the clause generated by this function is connected with OR:

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

Description: Or_where () formerly known as Orwhere (), the latter is obsolete.

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

Generates a WHERE field in (' Item ', ' item ') query statement, if appropriate, connected with and.

$names = Array (' Frank ', ' Todd ', ' James ');
$this->db->where_in (' username ', $names);
Build: WHERE username in (' Frank ', ' Todd ', ' James ')

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

Generate a WHERE field in (' Item ', ' item ') query statement, if appropriate, connected with OR.

$names = Array (' Frank ', ' Todd ', ' James ');
$this->db->or_where_in (' username ', $names);
Generated: OR username in (' Frank ', ' Todd ', ' James ')

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

Generates a WHERE field not in (' Item ', ' item ') query statement, if appropriate, connected with and.

$names = Array (' Frank ', ' Todd ', ' James ');
$this->db->where_not_in (' username ', $names);
Build: WHERE username not in (' Frank ', ' Todd ', ' James ')

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

Generates a WHERE field not in (' Item ', ' item ') query statement, if appropriate, connected with OR.

$names = Array (' Frank ', ' Todd ', ' James ');
$this->db->or_where_not_in (' username ', $names);
Generated: OR username not in (' Frank ', ' Todd ', ' James ')

More interested in CodeIgniter related content readers can view the site topics: "CodeIgniter Introductory Course", "CI (CodeIgniter) Framework Advanced Course", "PHP Excellent Development Framework Summary", "thinkphp Introductory Course", " Thinkphp Common Methods Summary, "Zend Framework Introduction Course", "PHP object-oriented Programming Introduction Course", "Php+mysql Database operation Introduction Tutorial" and "PHP common database Operation Skills Summary"

I hope this article will help you with the PHP program design based on CodeIgniter framework.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.