MySQL database function library

xiaoxiao2021-03-06  21

MySQL database function library

Author: DDVIP Updated: Ideal Source: Unknown Last update: 2004-07-01 Submission-mail: tg * ddvip.com

This function library is supplied with a MySQL database. For details on mysql, download the MySQL database, please rate at this website http://www.mysql.com. There are also many user interface programs that provide mysql, which is recommended to download phpMyAdmin to http://www.phpwizard.net/phpmyadmin, you can use browser to manage MySQL. The entire PHPMYADMIN program is done with php3, and the PHP3 and MySQL link can also be studied. MySQL_AFFECTED_ROWS: Get the number of columns affected by MySQL last operations. mysql_close: Turn off the MySQL server connection. MySQL_Connect: Open the MySQL server connection. MySQL_CREATE_DB: Create a MySQL new database. MySQL_DATA_SEEK: The internal return pointer is moved. MySQL_DB_QUERY: Send query string (query) to the mysql database. MySQL_DROP_DB: Remove the database. MySQL_ERRNO: Returns the error message code. MySQL_ERROR: Returns an error message. MySQL_FETCH_ARRAY: Returns an array of data. MySQL_FETCH_FIELD: Take the field information. MySQL_FETCH_LENGTHS: Returns the maximum length of the single column of each column. MySQL_FETCH_OBJECT: Returns class information. MySQL_FETCH_ROW: Returns the fields of single columns. MySQL_Field_name: Returns the name of the specified field. MySQL_Field_seek: Configure a certain point to the return value. MySQL_Field_Table: Get the name of the information table (Table) name of the current field. MySQL_Field_Type: Get the type of current field. MySQL_Field_Flags: Get the logo of the current field. MySQL_Field_len: Get the length of the current field. MySQL_Free_Result: Release returns to occupy memory. MySQL_INSERT_ID: Returns the last ID of the INSERT instruction. Mysql_list_fields: List the field (field) of the specified data sheet. MySQL_LIST_DBS: Lists databases available to the MySQL server. Mysql_list_tables: List the data sheet (Table) of the specified database. MySQL_NUM_FIELDS: Number of returned fields. MySQL_NUM_ROWS: Number of returned columns. MySQL_PConnect: Open the MySQL server to continuously. MySQL_QUERY: Send a query string. MySQL_RESULT: A result of acquiring query (Query). MySQL_SELECT_DB: Select a database. MySQL_TABLENAME: Name of the data sheet. MySQL_AFFECTED_ROWS gets the number of columns affected by MySQL last operations. Syntax: INT mysql_affected_rows (int [link_identifier]); Return Value: Integer Function Category: Database Function Description: This function can get the number of column (ROW) affected by MySQL last query operation INSERT, UPDATE, or DELETE. If the last query (query) is using DELETE and does not use the where command, all information will be deleted, and the function will return 0. If the last use Select is used, this function will not be expected, because it is valid if you want to change the Mysql database this function, and you want to use the mysql_num_rows () function if you want to get the number of SELECT returns. MySQL_Close Close the MySQL server connection. Syntax: INT mysql_close (int [link_identifier]); Return Value: Integer Function Type: Database Function Description: This function offs the connection with the MySQL database server.

If you do not specify parameters, Link_Identifier will turn off the last connection. This function is not available with the mysql_pconnect () connection. In fact, this function is not necessarily required. After the PHP willtep, the non-persistent connection to the database will be automatically turned off. Successfully returned true, failed to return false values. Reference: mysql_connect () MySQL_PConnect () mysql_connect Opens the MySQL server connection. Syntax: int mysql_connect (String [Hostname], String [PASSWORD]); Return Value: Integer Function Type: Database Function Description: This function establishes a connection to the MySQL server. All of these parameters can be omitted. When using this function but does not add any parameters, the default value of the parameter hostname is localhost, the default value of the parameter username is the owner of the PHP execution itine, the parameter password is an empty string (ie there is no password). The parameter hostname can be used to colon with the number, and the representative uses that port with mySQL. Of course, when using the database, use mysql_close () to turn off the connection to save resources. Example This is an example provided by an unknown netizen (18-Feb-1999) webmaster ";} $ row = mysql_fetch_row ($ r); echo" The number you are using in the future: "$ row [0];?>> Reference: mysql_close () MySQL_PConnect () mysql_create_db creates a MySQL new database. Syntax: int mysql_create_db (string database name, int [link_identifier]); Return Value: Integer Function Type: Database Function Description: This function is used to establish a new database (Database). Before being created, you must be connected to the server first. Reference: mysql_drop_db () mysql_data_seek mobile internal returns pointer. Syntax: INT mysql_data_seek (int result_identifier, int inter); Return Value: Integer Function Type: Database Function Description: This function can move the inside returned column pointer to the specified row_number. If you use mysql_fetch_row (), you can return the value of the new column. Successfully returns true, returns false. MySQL_DB_QUERY Sends Query to MySQL Database.

Syntax: int mysql_db_query (String Database, String Query, INT [LINK_IDENTIFIER]); Return Value: Integer Function Type: Database Function Description: This function is used to send query strings (query) to the backend MySQL database. If the parameters that can be omitted, if there is no existence, the program will automatically find the connection code after the other mysql_connect () connection. When an error occurs, false is returned, and other returns are returned when there is no mistake. Reference: mysql_connect () MySQL_DROP_DB Remove Database. Syntax: int mysql_drop_db (string database_name, int [link_identifier]); Return Value: Integer Function Type: Database Function Description: This function removes the existing database. Successfully returns true, returns false. Reference: mysql_create_db () mysql_errno returns an error message code. Syntax: int mysql_errno (int [link_identifier]); Return Value: Integer Function Type: Database Function Description: This function can get the error code of the mysql database server. Usually used in the PHP webpage development phase, as the PHP and MySQL amplifies. Use example "; mysql_select_db (" nonexistentdb "); echo mysql_ERRNO ().": ".Mysql_ERROR (). "
"; $ conn = mysql_query ("select * from nonexistentable"); echo mysql_errno (). ":" .MYSQL_ERROR (). "
"; Syntax: string mysql_error (int [link_identifier]); Return Value: String Function Category: Database Function Description: This function can get the error message of the mysql database server. Usually used in the PHP webpage program development phase, with mysql_errno () as a PHP and MySQL amplifiable. Reference: mysql_errno () MySQL_FETCH_ARRAY Returns an array of information. Syntax: Array MySQL_FETCH_ARRAY (int result, int [result_typ]); Return Value: Array Function Category: Database Function Description: This function is used to remove the query result result in the array variable. If Result is not available, return false values. This function can be said to be a enhancement function of mysql_fetch_row (), in addition to the return column and digital index into the array, you can also place the text index into an array. If several returns fields are the same text name, the last field is valid, the solution is to use a digital index or tap the name (Alias) for these same names. Caution  Note that the use of this function is not slower than the mysql_fetch_row () function, which function is used to use the demand for use. The parameter result_typ is a constant value with several constants mysql_assoc, MySQL_NUM and MySQL_BOTH.

Use example mysql_fetch_field acquisition field information. Syntax: Object MySQL_FETCH_FIELD (int result, int [field_offset); return value: Class Function Category: Database Function Description: This function returns to the class data for the Result (Column) information. The attributes of the return class are as follows: Name - Field Name Table - Form Name Max_Length - Field Maximum length not_null - If this is said that this field cannot be empty (null) primary_key - if 1 means this field is the main PRIMARY Key Unique_Key - If the item is the unique key Multiple_key - if 1 means this field is a recreational key (Non-Unique Key) Numeric - if 1 means this field is Digital BLOB - If 1 means that this field is a bit type (blob) Type - field type unsigned - if this is a nonsigned (unsigned) zerofill - if 1 means this field is zero filled (ZERO-FILED) Reference: mysql_field_seek () mysql_fetch_length returns the maximum length of the single column of each column. Syntax: Array MySQL_FETCH_LENGTHS (Int Result); Return Value: Array Function Type: Database Function Description: This function puts the maximum length of each field of the last column of mysql_fetch_row (). The maximum length is placed in the array variable. Returns the false value if the execution fails. The first data index value of the returned array is zero. Reference: mysql_fetch_row () MySQL_FETCH_Object Returns class data. Syntax: Object MySQL_FETCH_OBJECT (int result, int [result_typ]); Return Value: Class Function Category: Database Function Description: This function is used to remove the query result result in the class variable. Using methods and mysql_fetch_array () almost the same, different places are that this function returns to the information is an array. If Result is not available, return false values. In addition, the place where the cured paying attention is that the index of the type of information retrieved can only be text and cannot be used, which is because the characteristics of the class. All attributes in the characteristics of the class cannot be a number, so I have to use the text string as an index. The parameter result_typ is a constant value with several constants mysql_assoc, MySQL_NUM and MySQL_BOTH. With regard to the speed, the processing speed of this function is almost similar to the mysql_fetch_row () and mySQL_FETCH_ARRAY () two functions. Which function is used to use the demand for use. Use the example below to demonstrate as the returned class.

user_id Echo $ row-> fullname;} mysql_free_result ($ result);?> Reference: mysql_fetch_rlight () mysql_fetch_row () mysql_fetch_row Returns a single column of fields. Syntax: Array MySQL_FETCH_ROW (Int Result); Return Value: Array Function Category: Database Function Description: This function is used to remove a single column of the query results Result to array variables. The index of the array is a digital index, and the first index value is 0. If Result is not available, return false values. Reference: mysql_fetch_Array () mysql_fetch_Object () mysql_data_seek () mysql_fetch_lengths () mysql_Result () mysql_field_name Returns the name of the specified field. Syntax: string mysql_field_name (int result, int field_index); Return Value: String Function Category: Database Function Description: This function is used to obtain the name of the specified field. Use the example mysql_field_name ($ Result, 2); mysql_field_seek configuration pointer to return to the ruled  a field. Syntax: INT mysql_field_seek; Retreat: Integer Function Type: Database Function Description: This function configures the current pointer to the returns a specific field. Reference: mysql_fetch_field () mysql_field_table Gets the Name of the Table of the Current Field. Syntax: string mysql_field_table (int result, int field_offset); Return Value: String Function Category: Database Function Description: This function can get the data table name of the current field. MySQL_Field_Type Gets the type of current field. Syntax: string mysql_field_type (int result, int field_offset); Return Value: String Function Type: Database Function Description: This function can get the type format of the current field. The returned string is the type of field, including int, real, string, blob .... The usage examples


"; echo" The field of this information table is as follows
"; WHILE ($ I <$ FIELDS) {$ TYPE = MySQL_Field_Type ($ Result, $ I); $ name = mysql_field_name ($ Result, $ I) $ g = mysql_field_len ($ RESULT, $ I); $ FLAGS = mysql_field_flags ($ Result, $ I); Echo $ TYPE. "". $ name. "" $ LEN. "" "" "" ". > "; $ i ;} mysql_close ();?> mysql_field_flags Get the logo of the current field. Syntax: string mysql_field_flags (int result, int field_offset); Return Value: String Function Category: Database Function Description: This function can get the current The flag of the field. If a field has several property flags, the returned flag is a string that connects these attributes, each attribute is separated by space, and can use expLode () to cut these strings. Returns possible is: not_null, primary_key, unique_key, multiple_key, blob, unsigned, zerofill, binary, enum, auto_increment, timestamp.mysql_field_len obtain the current length field syntax: int mysql_field_len (int result, int field_offset); return value: integer function types: Database Function Description: This function can get the length of the current field. Mysql_free_result release returns to occupy memory. Syntax: Boolean mysql_free_Result (int result); return value: Boolean Function Category: Database function Description: This function can release the current MySQL database Query returns the memory occupied. Generally only only used this function in the case where you are very worried, you may not be insufficient in the use of memory. PHP program will automatically release. Mysql_Insert_id returns the ID of the last use INSERT instruction. Syntax: INT mysql_insert_id (int [link_identifier]); return value: Integer function type: Database function content Description: This function can get the last time Use INSERT to the execution ID of the MySQL database. Sleibowitz@btcwcu.org (13-May-1999) indicates that the ID can be used in the PHP 3.0.7 version with Replace and use INSERT. MySQL_List_fields lists the fields (field) of the specified data sheet. Syntax: int mysql_list_fields (string database_name, string table_name, int [link_identifier]); Return Value: Integer Function Type: Database Function Description: This function can get all fields of the specified data sheet. The returned field information can be used by mysql_field_flags (), mysql_field_len (), mysql_field_name () and a function of mysql_field_type (). Returns -1 if there is an error. MySQL_LIST_DBS lists the database (Database) available for the MySQL server. Syntax: INT mysql_list_dbs (int [link_identifier]); return value: Integer function type: Database function content Description: This function can get the available database of the MySQL server. MySQL_LIST_TABLES lists the data table (Table) of the specified database.

Syntax: int mysql_list_tables (String Database, INT [LINK_IDENTIFIER]); Return Value: Integer Function Type: Database Function Description: This function can get all the data table names in the specified database. MySQL_NUM_FIELDS acquires the number of returns to the field. Syntax: INT mysql_num_fields (int result); Return Value: Integer Function Type: Database Function Description: This function can get the number of returns fields. Reference: mysql_db_query () mysql_query () mysql_fetch_field () mysql_num_rows () MySQL_NUM_ROWS Number of returns. Syntax: INT mysql_num_rows (int result); Return Value: Integer Function Type: Database Function Description: This function can get the number of returns. Reference: mysql_db_query () mysql_query () mysql_fetch_row () mysql_pconnect Opens the MySQL server to continuously connect. Syntax: int mysql_pconnect (String [Hostname], String [Password]); Return Value: Integer Function Type: Database Function Description: This function and mysql_connect () Like. Different places are to use this function to open the database, the program will first look for this function, if executed, returns the previously executed ID. Another difference is that this function cannot use mysql_close () to close the database. MySQL_QUERY sends a query string. Syntax: int mysql_query (string query, int [link_identifier]); return value: Integer function type: Database function content Description: This function sends a Query string for mysql to do related processing or execution. If you do not specify a link_identifier parameter, the program automatically looks for the recently opened ID. When the Query query string is Update, Insert and Delete, the return may be true or false; the string of the query is SELECT to return a new ID value. Joey@samaritan.com (09-FEB-1999) indicates that when it returns false, it is not performed, but there is no return value, but the string of queries has an error. Reference: mysql_db_query () mysql_select_db () mysql_connect () MySQL_RESULT gets the result of Query. Syntax: INT mysql_result (int result, int ution, mixed field); Return Value: Integer Function Type: Database Function Description: This function gets a Query result. The parameter field can be a field name, order, or the format of FieldName.tablename. When returning to the amount of data, you can use this function to process. When the database is large, the efficiency of this function has to be considered, and a function of more efficient mysql_fetch_row (), mysql_fetch_array () and mysql_fetch_object () can be used. MySQL_SELECT_DB Select a database. Syntax: int mysql_select_db (String Database_name, int [link_identifier]); Return Value: Integer Function Category: Database Function Description: This function selects the database in the MySQL server for later data query jobs. Successfully returns true, returns false. Reference: mysql_connect () mysql_pconnect () mysql_query () MySQL_TABLENAME obtains the data sheet name.

转载请注明原文地址:https://www.9cbs.com/read-39476.html

New Post(0)