Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the database operation function $this->db->where () in CI framework

Shulou Source: shulou.com Published: 2022-06-03 12:57:40 10月02日 Update

This article mainly shows you the "CI framework database operation function $this- > db- > where () how to use", the content is easy to understand, clear, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn "CI framework database operation function $this- > db- > where () how to use" this article.

The details are as follows:

The use of CI Framework Database Operation function this- > db- > where ()

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

If you set $this- > db- > where () to FALSE, the optional third parameter, 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, except that the clauses generated by this function are concatenated with OR:

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

Description: or_where () was previously called orwhere (), and the latter is out of date.

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

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

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

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

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

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

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

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

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

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

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

$names = array ('Frank',' Todd', 'James'); $this- > db- > or_where_not_in (' username', $names); / / generate: OR username NOT IN ('Frank',' Todd', 'James') is all the contents of this article entitled "Database Operation function $this- > db- > where () in CI Framework. Thank you for reading!" I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Generate function data database framework fit statement query content article learning help same outdated three parameters clauses fields easy to understand more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Apple NVidia Redmi Shulou Technology