Ezsql Class Introduction:
: http://www.jb51.net/codes/26393.html
Ezsql is a small, fast database operation class that makes it easy to operate various databases with PHP (MySQL, ORACLE8/9, InterBase, FireBird, PostgreSQL, Ms-sql, SQLite, SQLite C + + )。
At the beginning of your script is to include a PHP file. You can then use a smaller, easier set of ezsql functions instead of the standard PHP database functions.
It automatically caches query results, provides a series of simple function operations and extensions, and does not cause additional server overhead
It has excellent debugging function, so that you can quickly judge the execution process of SQL statement
The result that the Ezsql function can return is an object, an associative array, or an array of values
It can greatly shorten development time and, in most cases, will simplify your code, make it run faster, and easily debug and optimize your database query statements.
This is a small class that doesn't add a lot of overhead to your site.
The following methods are available in the class:
-$db->get_results– Read the dataset from the database (or previously cached datasets)
-$db->get_row-reads a single piece of data from the database (or previously cached data)
-$db->get_col– reads a column from the database specified data set (or previously cached dataset)
-$db->get_var-read a value from the database dataset (or previously cached data)
-$DB->query-executes an SQL statement (cached if there is data)
-$db->debug– Prints the last executed SQL statement with the returned result (if there is a result)
-$DB the structure and contents of->vardump– printing variables
-$db->select-Select a new database
-$DB->get_col_info– Get column information
-$db->donation– to donate money to the author
-$DB->escape– formatted string inserted into the database, eg:mysql_escape_string (Stripslashes ($STR))
-$db->flush– Clear Cache
-$db->get_cache– in exchange for cache
-$db->hide_errors– Hidden errors
-$db->register_error– Registration error
-$db->show_errors– Display Error
-$db->store_cache– Storage to cache
-$db->sysdate– Get system time
-$db = new db-to create a DB object.
WordPress has modified the ezsql and also made it available only for MySQL
Some of the class operations that WordPress modifies are the following functions:
function query ($query)
This function is the most basic function of wpdb, $query for SQL statements, submitted to the database query, the results are divided into two kinds of situations:
1. If it is "Insert|delete|update|replace", return the number of rows affected, and in the case of "insert|replace", use the $this->insert_id to record the newly inserted ID.
2. If "select", use the $this->last_result to write down the query result set and return the number of records rows to the query.
function Escape ($string)
Use a backslash to reference a string, which uses magic quotes.
function Insert ($table, $data)
This is the Insert record function, the first parameter is the field array of the table, and the second is the data array. Insert Data returns 1, otherwise 0.
function Update ($table, $data, $where)
This is the new record function, the first parameter is the field array of the table, the second is the data array, and the third is the condition array, which is a nane array. Updated to 1, otherwise 0.
function Get_var ($query =null, $x = 0, $y = 0)
If the $query is not empty, the query is executed first, and then the value of the Y row of column X is returned.
function Get_row ($query = null, $output = OBJECT, $y = 0)
Returns a row, $OUTPU specifies the type returned, either Array_a,array_n or OBJECT. The $y specifies the first few lines.
function Get_col ($query = null, $x = 0)
Returns a column $x the specified column.
function get_results ($query = null, $output = OBJECT)
Returns the query result set, which can be returned in Array_a,array_n or OBJECT three.
function Get_col_info ($info _type = ' name ', $col _offset =-1)
Returns the field information.
PHP database Operation class: Ezsql