Get the App
SLTechnology News&Howtos  ›  Development  › 

How to operate common functions of AR database in CI framework

Shulou Source: shulou.com Published: 2022-06-03 13:07:31 11月14日 Update

This article shows you how to CI framework AR database operation common functions, the content is concise and easy to understand, absolutely can make your eyes bright, through the detailed introduction of this article hope you can get something.

1. Query table records

$this- > db- > select (); / / Select query fields $this- > db- > select_max (); $this- > db- > select_min (); $this- > db- > select_avg (); $this- > db- > select_sum (); $this- > db- > from (); / Select table name $this- > db- > join (); $this- > db- > get (); / / get query results $this- > db- > get_where (); $this- > db- > where (); $this- > db- > or_where () $this- > db- > where_in (); $this- > db- > or_where_in (); $this- > db- > where_not_in (); $this- > db- > or_where_not_in (); $this- > db- > like (); $this- > db- > or_like (); $this- > db- > not_like (); $this- > db- > or_not_like (); $this- > db- > group_by (); $this- > db- > distinct (); $this- > db- > having (); $this- > db- > or_having () $this- > db- > order_by (); $this- > db- > limit (); $this- > db- > count_all_results ()

2. Add table records

$this- > db- > insert ()

3. Change the table record

$this- > db- > set (); $this- > db- > update ()

4. Delete table records

$this- > db- > delete ()

5. Clear the table record

$this- > db- > empty_table (); $this- > db- > truncate ()

6. Cache part

$this- > db- > start_cache () $this- > db- > stop_cache () $this- > db- > flush_cache ()

7. Result set

Result () / return object array result_array () / return two-dimensional array row () / return an object row_array () / return one-dimensional array num_rows () / / return rows of query num_fields () / / number of fields that return query results free_result () / / release the resource memory occupied by the query

8. Auxiliary query function

$this- > db- > insert_id () / / get the number of rows just inserted id$this- > db- > affected_rows () / / the number of rows affected by modification or insertion $this- > db- > count_all (); / / the total number of records added to the function where invalid $this- > db- > last_query () / / the last executed sql statement / / Note that the following two functions only return the sql statement and do not execute the sql statement $data = array ('name' = > $name,' email' = > $email, 'url' = > $url); $str = $this- > db- > insert_string (' table_name', $data); $data = array ('name' = > $name,' email' = > $email, 'url' = > $url); $where = "author_id = 1 AND status =' active'" $str = $this- > db- > update_string ('table_name', $data, $where); / / returns the update string in the correct format

PS: for detailed tips on the use of CodeIgniter, please refer to the online manual of this site:

CodeIgniter 2.2.4 user Guide:

Http://shouce.jb51.net/codeigniter2.2/

CodeIgniter 3.0 user Guide:

Http://shouce.jb51.net/codeigniter3.0/

The above content is how to CI framework AR database operation common functions, have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Queries functions results arrays statements commonly used data databases frames content fields objects skills guides users user guides knowledge selection concise concise Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux macOS Shulou Technology OPPO Reno Microsoft