Bill: discuz! x/database operation methods, Db::table, C::t

Source: Internet
Author: User
Tags delete key

function function
Db::table ($tablename) Gets the correct prefixed table name, transforms the database handle,
DB::d elete ($tablename, condition, number of bars limit) Delete data from a table
Db::insert ($tablename, data (array), whether to return the insertion ID, whether it is a replacement, whether silent) Inserting data operations
Db::update ($tablename, data (array) condition) Update action
Db::fetch (resource after query) Take an associative array from the result set, and note that if two or more columns in the result have the same field names, the last column takes precedence.
Db::fetch_first ($sql) Fetching the first data fetch of the query
Db::fetch_all ($sql) Query and Fetch
Db::result_first ($sql) The first field value of a query result set
Db::query ($sql) General Query
Db::num_rows (resource after query) Get record lumped number
Db::_execute (command, parameter) command to execute MySQL class
Db::limit (N,n) Returns the restriction string
Db::field (field name, $pid) Returns the in condition if an array is returned
Db::order (alias, method) Sort

Note: Due to the increased security detection of SQL in X1.5. So, if your SQL statement contains the function Load_file,hex,substring,if,ord,char at the beginning of the following. Or, the following operations are Intooutfile,intodumpfile,unionselect, (SELECT ') will be denied execution.

replace parameter function
%t table name,
%s string, if array is serialized
%f format strings by  %f style
%d integer
% i do not process
%n If NULL is 0, if array, use ', ' to split, otherwise add quotation marks
function function
C::t ($tablename ')->count () Get all rows of a table
C::t ($tablename ')->update (key value, $data) Update key Value data
C::t ($tablename ')->delete (key value) Delete key value data
C::t ($tablename ')->truncate () Clear table
C::t ($tablename ')->insert ($data, $return _insert_id, $replace) Inserting data
C::t ($tablename ')->fetch_all ($ids) Fetch data, which can be a single key value or multiple key-value arrays
C::t ($tablename ')->fetch_all_field () Fetch all the field names table
C::t ($tablename ')->range ($start, $limit, $sort) Fetch domain Range
C::t ($tablename ')->optimize () Optimizing tables

Original: http://wiki.blueidea.com/index.php?title=Discuz!X/Database Operation method

Bill: discuz! x/database operation methods, Db::table, C::t

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.