diff --git a/reference/mysql/functions/mysql-affected-rows.xml b/reference/mysql/functions/mysql-affected-rows.xml index 489d666530..e848193392 100644 --- a/reference/mysql/functions/mysql-affected-rows.xml +++ b/reference/mysql/functions/mysql-affected-rows.xml @@ -1,62 +1,62 @@ - + - - - mysql_affected_rows - Get number of affected rows in previous MySQL - operation - - - Description - - intmysql_affected_rows - resource - link_identifier - - - - mysql_affected_rows returns the number - of rows affected by the last INSERT, UPDATE or DELETE query - associated with link_identifier. If the - link identifier isn't specified, the last link opened by - mysql_connect is assumed. - - - - If you are using transactions, you need to call - mysql_affected_rows after your INSERT, - UPDATE, or DELETE query, not after the commit. - - - - If the last query was a DELETE query with no WHERE clause, all - of the records will have been deleted from the table but this - function will return zero with MySQL versions prior to 4.1.2. - - - - When using UPDATE, MySQL will not update columns where the new - value is the same as the old value. This creates the possibility - that mysql_affected_rows may not actually - equal the number of rows matched, only the number of rows that - were literally affected by the query. - - - The REPLACE statement first deletes the record with the same primary key and - then inserts the new record. This function returns the number of deleted - records plus the number of inserted records. - - - - To retrieve the number of rows returned by a SELECT, it is possible to - use also mysql_num_rows. - - - If the last query failed, this function will return -1. - - Delete-Query - + + + mysql_affected_rows + Get number of affected rows in previous MySQL + operation + + + Description + + intmysql_affected_rows + resource + link_identifier + + + + mysql_affected_rows returns the number + of rows affected by the last INSERT, UPDATE or DELETE query + associated with link_identifier. If the + link identifier isn't specified, the last link opened by + mysql_connect is assumed. + + + + If you are using transactions, you need to call + mysql_affected_rows after your INSERT, + UPDATE, or DELETE query, not after the commit. + + + + If the last query was a DELETE query with no WHERE clause, all + of the records will have been deleted from the table but this + function will return zero with MySQL versions prior to 4.1.2. + + + + When using UPDATE, MySQL will not update columns where the new + value is the same as the old value. This creates the possibility + that mysql_affected_rows may not actually + equal the number of rows matched, only the number of rows that + were literally affected by the query. + + + The REPLACE statement first deletes the record with the same primary key and + then inserts the new record. This function returns the number of deleted + records plus the number of inserted records. + + + + To retrieve the number of rows returned by a SELECT, it is possible to + use also mysql_num_rows. + + + If the last query failed, this function will return -1. + + Delete-Query + ]]> - - - The above example would produce the following output: - - + + + The above example would produce the following output: + + - - - - - - Update-Query - + + + + + + Update-Query + ]]> - - - The above example would produce the following output: - - + + + The above example would produce the following output: + + - - - - - See also mysql_num_rows, and - mysql_info. - - - + + + + + See also mysql_num_rows, and + mysql_info. + + + + - - - mysql_change_user - - Change logged in user of the active connection - - - - Description - - intmysql_change_user - stringuser - stringpassword - string - database - - resource - link_identifier - - - - mysql_change_user changes the logged in user - of the current active connection, or the connection given by the - optional link_identifier parameter. If a - database is specified, this will be the current database after - the user has been changed. If the new user and password - authorization fails, the current connected user stays active. - &return.success; - + + + mysql_change_user + + Change logged in user of the active connection + + + + Description + + intmysql_change_user + stringuser + stringpassword + string + database + + resource + link_identifier + + + + mysql_change_user changes the logged in user + of the current active connection, or the connection given by the + optional link_identifier parameter. If a + database is specified, this will be the current database after + the user has been changed. If the new user and password + authorization fails, the current connected user stays active. + &return.success; + - - - This deprecated function is only available in PHP 3 and requires MySQL - 3.23.3 or higher. - - - - + + + This deprecated function is only available in PHP 3 and requires MySQL + 3.23.3 or higher. + + + + + - - - mysql_client_encoding - Returns the name of the character set - - - Description - - stringmysql_client_encoding - resourcelink_identifier - - - mysql_client_encoding returns the default - character set name for the current connection. - - - - <function>mysql_client_encoding</function> example - + + + mysql_client_encoding + Returns the name of the character set + + + Description + + stringmysql_client_encoding + resourcelink_identifier + + + mysql_client_encoding returns the default + character set name for the current connection. + + + + <function>mysql_client_encoding</function> example + ]]> - - - The above example would produce the following output: - - + + + The above example would produce the following output: + + - - - - - See also - mysql_real_escape_string - - - + + + + + See also + mysql_real_escape_string + + + + - - - mysql_close - Close MySQL connection - - - Description - - boolmysql_close - resource - link_identifier - - - - &return.success; - - mysql_close closes the connection to - the MySQL server that's associated with the specified link - identifier. If link_identifier isn't - specified, the last opened link is used. - - - Using mysql_close isn't usually necessary, - as non-persistent open links are automatically closed at the end - of the script's execution. See also - freeing - resources. - - - - mysql_close will not close persistent links - created by mysql_pconnect. - - - - - <function>mysql_close</function> example - + + + mysql_close + Close MySQL connection + + + Description + + boolmysql_close + resource + link_identifier + + + + &return.success; + + mysql_close closes the connection to + the MySQL server that's associated with the specified link + identifier. If link_identifier isn't + specified, the last opened link is used. + + + Using mysql_close isn't usually necessary, + as non-persistent open links are automatically closed at the end + of the script's execution. See also + freeing + resources. + + + + mysql_close will not close persistent links + created by mysql_pconnect. + + + + + <function>mysql_close</function> example + ]]> - - - - - See also mysql_connect and - mysql_pconnect. - - - + + + + + See also mysql_connect and + mysql_pconnect. + + + + - - - mysql_create_db - Create a MySQL database - - - Description - - boolmysql_create_db - stringdatabase_name - resource - link_identifier - - - - mysql_create_db attempts to create a new - database on the server associated with the specified link - identifier. - - - &return.success; - - - - The function mysql_create_db is deprecated. It - is preferable to use mysql_query to issue a sql - CREATE DATABASE statement instead. - - - - - <function>mysql_create_db</function> alternative example - + + + mysql_create_db + Create a MySQL database + + + Description + + boolmysql_create_db + stringdatabase_name + resource + link_identifier + + + + mysql_create_db attempts to create a new + database on the server associated with the specified link + identifier. + + + &return.success; + + + + The function mysql_create_db is deprecated. It + is preferable to use mysql_query to issue a sql + CREATE DATABASE statement instead. + + + + + <function>mysql_create_db</function> alternative example + ]]> - - - - - For downwards compatibility mysql_createdb - can also be used. This is deprecated, however. - - - - This function will not be available - if the MySQL extension was built against a MySQL 4.x client library. - - - - See also mysql_query. - - - + + + + + For downwards compatibility mysql_createdb + can also be used. This is deprecated, however. + + + + This function will not be available + if the MySQL extension was built against a MySQL 4.x client library. + + + + See also mysql_query. + + + + - - - mysql_data_seek - Move internal result pointer - - - Description - - boolmysql_data_seek - resourceresult_identifier - introw_number - - - mysql_data_seek moves the internal row - pointer of the MySQL result associated with the specified result - identifier to point to the specified row number. The next call - to mysql_fetch_row would return that row. - - - &return.success; - - - row_number starts at 0. The - row_number should be a value in the range from 0 to - mysql_num_rows - 1. However if the result set - is empty (mysql_num_rows == 0), a seek to 0 will - fail with a E_WARNING and - mysql_data_seek will return &false;. - - - - The function mysql_data_seek can be used in - conjunction only with mysql_query, not with - mysql_unbuffered_query. - - - - - <function>mysql_data_seek</function> example - + + + mysql_data_seek + Move internal result pointer + + + Description + + boolmysql_data_seek + resourceresult_identifier + introw_number + + + mysql_data_seek moves the internal row + pointer of the MySQL result associated with the specified result + identifier to point to the specified row number. The next call + to mysql_fetch_row would return that row. + + + &return.success; + + + row_number starts at 0. The + row_number should be a value in the range from 0 to + mysql_num_rows - 1. However if the result set + is empty (mysql_num_rows == 0), a seek to 0 will + fail with a E_WARNING and + mysql_data_seek will return &false;. + + + + The function mysql_data_seek can be used in + conjunction only with mysql_query, not with + mysql_unbuffered_query. + + + + + <function>mysql_data_seek</function> example + = 0; $i--) { mysql_free_result($result); ?> ]]> - - - - - See also - mysql_query, - mysql_num_rows, - mysql_fetch_row, - mysql_fetch_assoc, - mysql_fetch_array, and - mysql_fetch_object. - - - + + + + + See also + mysql_query, + mysql_num_rows, + mysql_fetch_row, + mysql_fetch_assoc, + mysql_fetch_array, and + mysql_fetch_object. + + + + - - - mysql_db_name - Get result data - - - Description - - stringmysql_db_name - resourceresult - introw - mixed - field - - - - mysql_db_name takes as its first parameter - the result pointer from a call to - mysql_list_dbs. The - row parameter is an index into the result - set. - - - If an error occurs, &false; is returned. Use - mysql_errno and - mysql_error to determine the nature of the - error. - - - - <function>mysql_db_name</function> example - + + + mysql_db_name + Get result data + + + Description + + stringmysql_db_name + resourceresult + introw + mixed + field + + + + mysql_db_name takes as its first parameter + the result pointer from a call to + mysql_list_dbs. The + row parameter is an index into the result + set. + + + If an error occurs, &false; is returned. Use + mysql_errno and + mysql_error to determine the nature of the + error. + + + + <function>mysql_db_name</function> example + ]]> - - - - - For backward compatibility, mysql_dbname is - also accepted. This is deprecated, however. - - - See also - mysql_list_dbs, and - mysql_tablename. - - - + + + + + For backward compatibility, mysql_dbname is + also accepted. This is deprecated, however. + + + See also + mysql_list_dbs, and + mysql_tablename. + + + + - - - mysql_db_query - Send a MySQL query - - - Description - - resourcemysql_db_query - stringdatabase - stringquery - resource - link_identifier - - - - Returns a positive MySQL result resource to the query result, - or &false; on error. The function also returns &true;/&false; for - INSERT/UPDATE/DELETE - queries to indicate success/failure. - - - - This function has been deprecated since PHP 4.0.6. - Do not use this function. Use mysql_select_db - and mysql_query instead. - - - - mysql_db_query selects a database and - executes a query on it. If the optional link identifier isn't - specified, the function will try to find an open link to the - MySQL server and if no such link is found it'll try to create one - as if mysql_connect was called with no - arguments. - - - Be aware that this function does NOT - switch back to the database you were connected before. In other words, - you can't use this function to temporarily run a - sql query on another database, you would have to manually switch back. - Users are strongly encouraged to use the - database.table syntax in their sql queries or - mysql_select_db instead of this function. - - - - <function>mysql_db_query</function> alternative example - + + + mysql_db_query + Send a MySQL query + + + Description + + resourcemysql_db_query + stringdatabase + stringquery + resource + link_identifier + + + + Returns a positive MySQL result resource to the query result, + or &false; on error. The function also returns &true;/&false; for + INSERT/UPDATE/DELETE + queries to indicate success/failure. + + + + This function has been deprecated since PHP 4.0.6. + Do not use this function. Use mysql_select_db + and mysql_query instead. + + + + mysql_db_query selects a database and + executes a query on it. If the optional link identifier isn't + specified, the function will try to find an open link to the + MySQL server and if no such link is found it'll try to create one + as if mysql_connect was called with no + arguments. + + + Be aware that this function does NOT + switch back to the database you were connected before. In other words, + you can't use this function to temporarily run a + sql query on another database, you would have to manually switch back. + Users are strongly encouraged to use the + database.table syntax in their sql queries or + mysql_select_db instead of this function. + + + + <function>mysql_db_query</function> alternative example + ]]> - - - - - See also mysql_connect and - mysql_query. - - - + + + + + See also mysql_connect and + mysql_query. + + + + - - - mysql_drop_db - Drop (delete) a MySQL database - - - Description - - boolmysql_drop_db - stringdatabase_name - resource - link_identifier - - - - mysql_drop_db attempts to drop (remove) an - entire database from the server associated with the specified - link identifier. - - - &return.success; - - - For downward compatibility mysql_dropdb - can also be used. This is also deprecated, however. - - - - The function mysql_drop_db is deprecated. It is - preferable to use mysql_query to issue a sql - DROP DATABASE statement instead. - - - - - <function>mysql_drop_db</function> alternative example - + + + mysql_drop_db + Drop (delete) a MySQL database + + + Description + + boolmysql_drop_db + stringdatabase_name + resource + link_identifier + + + + mysql_drop_db attempts to drop (remove) an + entire database from the server associated with the specified + link identifier. + + + &return.success; + + + For downward compatibility mysql_dropdb + can also be used. This is also deprecated, however. + + + + The function mysql_drop_db is deprecated. It is + preferable to use mysql_query to issue a sql + DROP DATABASE statement instead. + + + + + <function>mysql_drop_db</function> alternative example + ]]> - - - - - - This function will not be available - if the MySQL extension was built against a MySQL 4.x client library. - - - - See also mysql_query. - - - + + + + + + This function will not be available + if the MySQL extension was built against a MySQL 4.x client library. + + + + See also mysql_query. + + + + - - - mysql_errno - - Returns the numerical value of the error message from previous - MySQL operation - - - - Description - - intmysql_errno - resource - link_identifier - - - - Returns the error number from the last MySQL function, or - 0 (zero) if no error occurred. - - - Errors coming back from the MySQL database backend no longer - issue warnings. Instead, use mysql_errno to - retrieve the error code. Note that this function only returns the - error code from the most recently executed MySQL function (not - including mysql_error and - mysql_errno), so if you want to use it, - make sure you check the value before calling another MySQL - function. - - <function>mysql_errno</function> example - + + + mysql_errno + + Returns the numerical value of the error message from previous + MySQL operation + + + + Description + + intmysql_errno + resource + link_identifier + + + + Returns the error number from the last MySQL function, or + 0 (zero) if no error occurred. + + + Errors coming back from the MySQL database backend no longer + issue warnings. Instead, use mysql_errno to + retrieve the error code. Note that this function only returns the + error code from the most recently executed MySQL function (not + including mysql_error and + mysql_errno), so if you want to use it, + make sure you check the value before calling another MySQL + function. + + <function>mysql_errno</function> example + ]]> - - - The above example would produce the following output: - - + + + The above example would produce the following output: + + - - - - - - If the optional argument is specified the given link - is used to retrieve the error code. If not, the last - opened link is used. - - - - See also mysql_error and - MySQL error codes. - - - + + + + + + If the optional argument is specified the given link + is used to retrieve the error code. If not, the last + opened link is used. + + + + See also mysql_error and + MySQL error codes. + + + + - - - mysql_error - - Returns the text of the error message from previous MySQL - operation - - - - Description - - stringmysql_error - resource - link_identifier - - - - Returns the error text from the last MySQL function, or - '' (the empty string) if no error occurred. - If no link is explicitly passed to the function, the last - successful open link will be used to retrieve the error message - from the MySQL server. - - - Errors coming back from the MySQL database backend no longer - issue warnings. Instead, use mysql_error to - retrieve the error text. Note that this function only returns the - error text from the most recently executed MySQL function (not - including mysql_error and - mysql_errno), so if you want to use it, make - sure you check the value before calling another MySQL function. - - <function>mysql_error</function> example - + + + mysql_error + + Returns the text of the error message from previous MySQL + operation + + + + Description + + stringmysql_error + resource + link_identifier + + + + Returns the error text from the last MySQL function, or + '' (the empty string) if no error occurred. + If no link is explicitly passed to the function, the last + successful open link will be used to retrieve the error message + from the MySQL server. + + + Errors coming back from the MySQL database backend no longer + issue warnings. Instead, use mysql_error to + retrieve the error text. Note that this function only returns the + error text from the most recently executed MySQL function (not + including mysql_error and + mysql_errno), so if you want to use it, make + sure you check the value before calling another MySQL function. + + <function>mysql_error</function> example + ]]> - - - The above example would produce the following output: - - + + + The above example would produce the following output: + + - - - - - See also mysql_errno and - MySQL error messages. - - - + + + + + See also mysql_errno and + MySQL error messages. + + + + - - - mysql_escape_string - - Escapes a string for use in a mysql_query - - - - Description - - stringmysql_escape_string - stringunescaped_string - - - This function will escape the unescaped_string, - so that it is safe to place it in a mysql_query. - - - - mysql_escape_string does not escape - % and _. - - - This function is identical to mysql_real_escape_string except that - mysql_real_escape_string takes a connection handler and escapes the - string according to the current character - set. mysql_escape_string does not take a - connection argument and does not respect the current charset setting. - - - - - <function>mysql_escape_string</function> example - + + + mysql_escape_string + + Escapes a string for use in a mysql_query + + + + Description + + stringmysql_escape_string + stringunescaped_string + + + This function will escape the unescaped_string, + so that it is safe to place it in a mysql_query. + + + + mysql_escape_string does not escape + % and _. + + + This function is identical to mysql_real_escape_string except that + mysql_real_escape_string takes a connection handler and escapes the + string according to the current character + set. mysql_escape_string does not take a + connection argument and does not respect the current charset setting. + + + + + <function>mysql_escape_string</function> example + ]]> - - - The above example would produce the following output: - - + + + The above example would produce the following output: + + - - - - - - - This function has been deprecated since PHP 4.3.0. - Do not use this function. Use mysql_real_escape_string - instead. - - - - - See also - mysql_real_escape_string, - addslashes and the - magic_quotes_gpc - directive. - - - + + + + + + + This function has been deprecated since PHP 4.3.0. + Do not use this function. Use mysql_real_escape_string + instead. + + + + + See also + mysql_real_escape_string, + addslashes and the + magic_quotes_gpc + directive. + + + + - - - mysql_fetch_array - - Fetch a result row as an associative array, a numeric array, or both - - - - Description - - arraymysql_fetch_array - resourceresult - int - result_type - - - - Returns an array that corresponds to the fetched row, or &false; - if there are no more rows. - - mysql_fetch_array is an extended version of - mysql_fetch_row. In addition to storing the - data in the numeric indices of the result array, it also stores - the data in associative indices, using the field names as keys. - - - If two or more columns of the result have the same field names, - the last column will take precedence. To access the other column(s) - of the same name, you must use the numeric index of the column or - make an alias for the column. For aliased columns, you cannot - access the contents with the original column name (by using - 'field' in this example). - - Query with aliased duplicate field names - + + + mysql_fetch_array + + Fetch a result row as an associative array, a numeric array, or both + + + + Description + + arraymysql_fetch_array + resourceresult + int + result_type + + + + Returns an array that corresponds to the fetched row, or &false; + if there are no more rows. + + mysql_fetch_array is an extended version of + mysql_fetch_row. In addition to storing the + data in the numeric indices of the result array, it also stores + the data in associative indices, using the field names as keys. + + + If two or more columns of the result have the same field names, + the last column will take precedence. To access the other column(s) + of the same name, you must use the numeric index of the column or + make an alias for the column. For aliased columns, you cannot + access the contents with the original column name (by using + 'field' in this example). + + Query with aliased duplicate field names + - - - - - An important thing to note is that using - mysql_fetch_array is not - significantly slower than using - mysql_fetch_row, while it provides - a significant added value. - - - The optional second argument result_type - in mysql_fetch_array is a constant and can - take the following values: MYSQL_ASSOC, - MYSQL_NUM, and MYSQL_BOTH. - This feature was added in PHP 3.0.7. MYSQL_BOTH - is the default for this argument. - - - By using MYSQL_BOTH, you'll get an array - with both associative and number indices. Using - MYSQL_ASSOC, you only get associative - indices (as mysql_fetch_assoc works), - using MYSQL_NUM, you only get number indices (as - mysql_fetch_row works). - - &database.field-case; - &database.fetch-null; - - - - <function>mysql_fetch_array</function> with - <constant>MYSQL_NUM</constant> - - + + + + + An important thing to note is that using + mysql_fetch_array is not + significantly slower than using + mysql_fetch_row, while it provides + a significant added value. + + + The optional second argument result_type + in mysql_fetch_array is a constant and can + take the following values: MYSQL_ASSOC, + MYSQL_NUM, and MYSQL_BOTH. + This feature was added in PHP 3.0.7. MYSQL_BOTH + is the default for this argument. + + + By using MYSQL_BOTH, you'll get an array + with both associative and number indices. Using + MYSQL_ASSOC, you only get associative + indices (as mysql_fetch_assoc works), + using MYSQL_NUM, you only get number indices (as + mysql_fetch_row works). + + &database.field-case; + &database.fetch-null; + + + + <function>mysql_fetch_array</function> with + <constant>MYSQL_NUM</constant> + + ]]> - - - - - <function>mysql_fetch_array</function> with <constant>MYSQL_ASSOC</constant> - - + + + + + <function>mysql_fetch_array</function> with <constant>MYSQL_ASSOC</constant> + + ]]> - - - - - <function>mysql_fetch_array</function> with <constant>MYSQL_BOTH</constant> - - + + + + + <function>mysql_fetch_array</function> with <constant>MYSQL_BOTH</constant> + + ]]> - - - - - See also - mysql_fetch_row, - mysql_fetch_assoc, - mysql_data_seek and - mysql_query. - - - + + + + + See also + mysql_fetch_row, + mysql_fetch_assoc, + mysql_data_seek and + mysql_query. + + + + - - - mysql_fetch_assoc - - Fetch a result row as an associative array - - - - Description - - arraymysql_fetch_assoc - resourceresult - - - Returns an associative array that corresponds to the fetched row, - or &false; if there are no more rows. - - mysql_fetch_assoc is equivalent to calling - mysql_fetch_array with MYSQL_ASSOC for the - optional second parameter. It only returns an associative array. - This is the way mysql_fetch_array originally - worked. If you need the numeric indices as well as the - associative, use mysql_fetch_array. - - - If two or more columns of the result have the same field names, - the last column will take precedence. To access the other - column(s) of the same name, you either need to access the - result with numeric indices by using - mysql_fetch_row or add alias names. - See the example at the mysql_fetch_array - description about aliases. - - - An important thing to note is that using - mysql_fetch_assoc is not - significantly slower than using - mysql_fetch_row, while it - provides a significant added value. - - &database.field-case; - &database.fetch-null; - - - An expanded <function>mysql_fetch_assoc</function> example - + + + mysql_fetch_assoc + + Fetch a result row as an associative array + + + + Description + + arraymysql_fetch_assoc + resourceresult + + + Returns an associative array that corresponds to the fetched row, + or &false; if there are no more rows. + + mysql_fetch_assoc is equivalent to calling + mysql_fetch_array with MYSQL_ASSOC for the + optional second parameter. It only returns an associative array. + This is the way mysql_fetch_array originally + worked. If you need the numeric indices as well as the + associative, use mysql_fetch_array. + + + If two or more columns of the result have the same field names, + the last column will take precedence. To access the other + column(s) of the same name, you either need to access the + result with numeric indices by using + mysql_fetch_row or add alias names. + See the example at the mysql_fetch_array + description about aliases. + + + An important thing to note is that using + mysql_fetch_assoc is not + significantly slower than using + mysql_fetch_row, while it + provides a significant added value. + + &database.field-case; + &database.fetch-null; + + + An expanded <function>mysql_fetch_assoc</function> example + ]]> - - - - - See also - mysql_fetch_row, - mysql_fetch_array, - mysql_data_seek, - mysql_query and - mysql_error. - - - + + + + + See also + mysql_fetch_row, + mysql_fetch_array, + mysql_data_seek, + mysql_query and + mysql_error. + + + + - - - mysql_fetch_field - - Get column information from a result and return as an object - - - - Description - - objectmysql_fetch_field - resourceresult - int - field_offset - - - - Returns an object containing field information. - - - mysql_fetch_field can be used in order to - obtain information about fields in a certain query result. If - the field offset isn't specified, the next field that wasn't yet - retrieved by mysql_fetch_field is retrieved. - - - The properties of the object are: - - - - name - column name - - - - - table - name of the table the column belongs to - - - - - max_length - maximum length of the column - - - - - not_null - 1 if the column cannot be &null; - - - - - primary_key - 1 if the column is a primary key - - - - - unique_key - 1 if the column is a unique key - - - - - multiple_key - 1 if the column is a non-unique key - - - - - numeric - 1 if the column is numeric - - - - - blob - 1 if the column is a BLOB - - - - - type - the type of the column - - - - - unsigned - 1 if the column is unsigned - - - - - zerofill - 1 if the column is zero-filled - - - - - &database.field-case; - - - <function>mysql_fetch_field</function> example - + + + mysql_fetch_field + + Get column information from a result and return as an object + + + + Description + + objectmysql_fetch_field + resourceresult + int + field_offset + + + + Returns an object containing field information. + + + mysql_fetch_field can be used in order to + obtain information about fields in a certain query result. If + the field offset isn't specified, the next field that wasn't yet + retrieved by mysql_fetch_field is retrieved. + + + The properties of the object are: + + + + name - column name + + + + + table - name of the table the column belongs to + + + + + max_length - maximum length of the column + + + + + not_null - 1 if the column cannot be &null; + + + + + primary_key - 1 if the column is a primary key + + + + + unique_key - 1 if the column is a unique key + + + + + multiple_key - 1 if the column is a non-unique key + + + + + numeric - 1 if the column is numeric + + + + + blob - 1 if the column is a BLOB + + + + + type - the type of the column + + + + + unsigned - 1 if the column is unsigned + + + + + zerofill - 1 if the column is zero-filled + + + + + &database.field-case; + + + <function>mysql_fetch_field</function> example + zerofill mysql_free_result($result); ?> ]]> - - - - - See also mysql_field_seek. - - - + + + + + See also mysql_field_seek. + + + + - - - mysql_fetch_lengths - - Get the length of each output in a result - - - - Description - - arraymysql_fetch_lengths - resourceresult - - - Returns an array that corresponds to the lengths of each field - in the last row fetched by mysql_fetch_row, - or &false; on error. - - - mysql_fetch_lengths stores the lengths of - each result column in the last row returned by - mysql_fetch_row, - mysql_fetch_assoc, - mysql_fetch_array, and - mysql_fetch_object in an array, starting at - offset 0. - - - - A <function>mysql_fetch_lengths</function> example - + + + mysql_fetch_lengths + + Get the length of each output in a result + + + + Description + + arraymysql_fetch_lengths + resourceresult + + + Returns an array that corresponds to the lengths of each field + in the last row fetched by mysql_fetch_row, + or &false; on error. + + + mysql_fetch_lengths stores the lengths of + each result column in the last row returned by + mysql_fetch_row, + mysql_fetch_assoc, + mysql_fetch_array, and + mysql_fetch_object in an array, starting at + offset 0. + + + + A <function>mysql_fetch_lengths</function> example + ]]> - - &example.outputs.similar; - + + &example.outputs.similar; + 16 ) ]]> - - - - - See also mysql_field_len, - mysql_fetch_row, and - strlen. - - - + + + + + See also mysql_field_len, + mysql_fetch_row, and + strlen. + + + + - - - mysql_fetch_object - Fetch a result row as an object - - - Description - - objectmysql_fetch_object - resourceresult - - - Returns an object with properties that correspond to the fetched - row, or &false; if there are no more rows. - - - mysql_fetch_object is similar to - mysql_fetch_array, with one difference - an - object is returned, instead of an array. Indirectly, that means - that you can only access the data by the field names, and not by - their offsets (numbers are illegal property names). - - &database.field-case; - &database.fetch-null; - - - <function>mysql_fetch_object</function> example - + + + mysql_fetch_object + Fetch a result row as an object + + + Description + + objectmysql_fetch_object + resourceresult + + + Returns an object with properties that correspond to the fetched + row, or &false; if there are no more rows. + + + mysql_fetch_object is similar to + mysql_fetch_array, with one difference - an + object is returned, instead of an array. Indirectly, that means + that you can only access the data by the field names, and not by + their offsets (numbers are illegal property names). + + &database.field-case; + &database.fetch-null; + + + <function>mysql_fetch_object</function> example + field; ?> ]]> - - - - - Speed-wise, the function is identical to - mysql_fetch_array, and almost as quick as - mysql_fetch_row (the difference is - insignificant). - - <function>mysql_fetch_object</function> example - + + + + + Speed-wise, the function is identical to + mysql_fetch_array, and almost as quick as + mysql_fetch_row (the difference is + insignificant). + + <function>mysql_fetch_object</function> example + ]]> - - - - - See also - mysql_fetch_array, - mysql_fetch_assoc, - mysql_fetch_row, - mysql_data_seek and - mysql_query. - - - + + + + + See also + mysql_fetch_array, + mysql_fetch_assoc, + mysql_fetch_row, + mysql_data_seek and + mysql_query. + + + + - - - mysql_fetch_row - Get a result row as an enumerated array - - - Description - - arraymysql_fetch_row - resourceresult - - - Returns an array that corresponds to the fetched row, or &false; - if there are no more rows. - - &database.fetch-null; - - mysql_fetch_row fetches one row of data from - the result associated with the specified result identifier. The - row is returned as an array. Each result column is stored in an - array offset, starting at offset 0. - - - Subsequent call to mysql_fetch_row would - return the next row in the result set, or &false; if there are no - more rows. - - - - Fetching one row with <function>mysql_fetch_row</function> - + + + mysql_fetch_row + Get a result row as an enumerated array + + + Description + + arraymysql_fetch_row + resourceresult + + + Returns an array that corresponds to the fetched row, or &false; + if there are no more rows. + + &database.fetch-null; + + mysql_fetch_row fetches one row of data from + the result associated with the specified result identifier. The + row is returned as an array. Each result column is stored in an + array offset, starting at offset 0. + + + Subsequent call to mysql_fetch_row would + return the next row in the result set, or &false; if there are no + more rows. + + + + Fetching one row with <function>mysql_fetch_row</function> + ]]> - - - - - See also - mysql_fetch_array, - mysql_fetch_assoc, - mysql_fetch_object, - mysql_data_seek, - mysql_fetch_lengths and - mysql_result. - - - + + + + + See also + mysql_fetch_array, + mysql_fetch_assoc, + mysql_fetch_object, + mysql_data_seek, + mysql_fetch_lengths and + mysql_result. + + + + - - - mysql_field_flags - - Get the flags associated with the specified field in a result - - - - Description - - stringmysql_field_flags - resourceresult - intfield_offset - - - mysql_field_flags returns the field flags of - the specified field. The flags are reported as a single word - per flag separated by a single space, so that you can split the - returned value using explode. - - The following flags are reported, if your version of MySQL - is current enough to support them: "not_null", - "primary_key", "unique_key", - "multiple_key", "blob", - "unsigned", "zerofill", - "binary", "enum", - "auto_increment" et "timestamp". - - - - A <function>mysql_field_flags</function> example - + + + mysql_field_flags + + Get the flags associated with the specified field in a result + + + + Description + + stringmysql_field_flags + resourceresult + intfield_offset + + + mysql_field_flags returns the field flags of + the specified field. The flags are reported as a single word + per flag separated by a single space, so that you can split the + returned value using explode. + + The following flags are reported, if your version of MySQL + is current enough to support them: "not_null", + "primary_key", "unique_key", + "multiple_key", "blob", + "unsigned", "zerofill", + "binary", "enum", + "auto_increment" et "timestamp". + + + + A <function>mysql_field_flags</function> example + ]]> - - &example.outputs.similar; - + + &example.outputs.similar; + auto_increment ) ]]> - - - - - For downward compatibility mysql_fieldflags - can also be used. This is deprecated, however. - - - + + + + + For downward compatibility mysql_fieldflags + can also be used. This is deprecated, however. + + + + - - - mysql_field_len - - Returns the length of the specified field - - - - Description - - intmysql_field_len - resourceresult - intfield_offset - - - mysql_field_len returns the length of the - specified field. - - - - <function>mysql_field_len</function> example - + + + mysql_field_len + + Returns the length of the specified field + + + + Description + + intmysql_field_len + resourceresult + intfield_offset + + + mysql_field_len returns the length of the + specified field. + + + + <function>mysql_field_len</function> example + ]]> - - - - - For downward compatibility mysql_fieldlen - can also be used. This is deprecated, however. - - - See also mysql_fetch_lengths and - strlen. - - - + + + + + For downward compatibility mysql_fieldlen + can also be used. This is deprecated, however. + + + See also mysql_fetch_lengths and + strlen. + + + + - - - mysql_field_name - - Get the name of the specified field in a result - - - - Description - - stringmysql_field_name - resourceresult - intfield_index - - - mysql_field_name returns the name of the - specified field index. result must be a - valid result identifier and field_index is - the numerical offset of the field. - - - - field_index starts at 0. - - - e.g. The index of the third field would actually be 2, the index - of the fourth field would be 3 and so on. - - - &database.field-case; - - - <function>mysql_field_name</function> example - + + + mysql_field_name + + Get the name of the specified field in a result + + + + Description + + stringmysql_field_name + resourceresult + intfield_index + + + mysql_field_name returns the name of the + specified field index. result must be a + valid result identifier and field_index is + the numerical offset of the field. + + + + field_index starts at 0. + + + e.g. The index of the third field would actually be 2, the index + of the fourth field would be 3 and so on. + + + &database.field-case; + + + <function>mysql_field_name</function> example + ]]> - - - The above example would produce the following output: - - + + + The above example would produce the following output: + + - - - - - For downwards compatibility mysql_fieldname - can also be used. This is deprecated, however. - - - + + + + + For downwards compatibility mysql_fieldname + can also be used. This is deprecated, however. + + + + - - - mysql_field_seek - - Set result pointer to a specified field offset - - - - Description - - intmysql_field_seek - resourceresult - intfield_offset - - - Seeks to the specified field offset. If the next call to - mysql_fetch_field doesn't include a field - offset, the field offset specified in - mysql_field_seek will be returned. - - - See also mysql_fetch_field. - - - + + + mysql_field_seek + + Set result pointer to a specified field offset + + + + Description + + intmysql_field_seek + resourceresult + intfield_offset + + + Seeks to the specified field offset. If the next call to + mysql_fetch_field doesn't include a field + offset, the field offset specified in + mysql_field_seek will be returned. + + + See also mysql_fetch_field. + + + + - - - mysql_field_table - - Get name of the table the specified field is in - - - - Description - - stringmysql_field_table - resourceresult - intfield_offset - - - Returns the name of the table that the specified field is - in. - - - - A <function>mysql_field_table</function> example - + + + mysql_field_table + + Get name of the table the specified field is in + + + + Description + + stringmysql_field_table + resourceresult + intfield_offset + + + Returns the name of the table that the specified field is + in. + + + + A <function>mysql_field_table</function> example + ]]> - - - - - For downward compatibility mysql_fieldtable - can also be used. This is deprecated, however. - - - See also mysql_list_tables. - - - + + + + + For downward compatibility mysql_fieldtable + can also be used. This is deprecated, however. + + + See also mysql_list_tables. + + + + - - - mysql_field_type - - Get the type of the specified field in a result - - - - Description - - stringmysql_field_type - resourceresult - intfield_offset - - - mysql_field_type is similar to the - mysql_field_name function. The arguments are - identical, but the field type is returned instead. The field type - will be one of "int", "real", - "string", "blob", and others as - detailed in the MySQL - documentation. - - <function>mysql_field_type</function> example - + + + mysql_field_type + + Get the type of the specified field in a result + + + + Description + + stringmysql_field_type + resourceresult + intfield_offset + + + mysql_field_type is similar to the + mysql_field_name function. The arguments are + identical, but the field type is returned instead. The field type + will be one of "int", "real", + "string", "blob", and others as + detailed in the MySQL + documentation. + + <function>mysql_field_type</function> example + ]]> - - - The above example would produce the following output: - - + + + The above example would produce the following output: + + - - - - - For downward compatibility mysql_fieldtype - can also be used. This is deprecated, however. - - - + + + + + For downward compatibility mysql_fieldtype + can also be used. This is deprecated, however. + + + + - - - mysql_free_result - Free result memory - - - Description - - boolmysql_free_result - resourceresult - - - mysql_free_result will free all memory - associated with the result identifier result. - - - mysql_free_result only needs to be called if - you are concerned about how much memory is being used for queries - that return large result sets. All associated result memory is - automatically freed at the end of the script's execution. - - - &return.success; - - - If a non-resource is used for the result, an - error of level E_WARNING will be emitted. It's worth noting that - mysql_query only returns a resource - for SELECT, SHOW, EXPLAIN, and DESCRIBE queries. - - - - A <function>mysql_free_result</function> example - + + + mysql_free_result + Free result memory + + + Description + + boolmysql_free_result + resourceresult + + + mysql_free_result will free all memory + associated with the result identifier result. + + + mysql_free_result only needs to be called if + you are concerned about how much memory is being used for queries + that return large result sets. All associated result memory is + automatically freed at the end of the script's execution. + + + &return.success; + + + If a non-resource is used for the result, an + error of level E_WARNING will be emitted. It's worth noting that + mysql_query only returns a resource + for SELECT, SHOW, EXPLAIN, and DESCRIBE queries. + + + + A <function>mysql_free_result</function> example + ]]> - - - - - For downward compatibility mysql_freeresult - can also be used. This is deprecated, however. - - - See also mysql_query and - is_resource. - - - + + + + + For downward compatibility mysql_freeresult + can also be used. This is deprecated, however. + + + See also mysql_query and + is_resource. + + + + - - - mysql_get_client_info - Get MySQL client info - - - Description - - stringmysql_get_client_info - - - - mysql_get_client_info returns a string that - represents the client library version. - - - - <function>mysql_get_client_info</function> example - + + + mysql_get_client_info + Get MySQL client info + + + Description + + stringmysql_get_client_info + + + + mysql_get_client_info returns a string that + represents the client library version. + + + + <function>mysql_get_client_info</function> example + ]]> - - - The above example would produce the following output: - - + + + The above example would produce the following output: + + - - - - - See also - mysql_get_host_info, - mysql_get_proto_info and - mysql_get_server_info. - - - + + + + + See also + mysql_get_host_info, + mysql_get_proto_info and + mysql_get_server_info. + + + + - - - mysql_get_host_info - Get MySQL host info - - - Description - - stringmysql_get_host_info - resourcelink_identifier - - - mysql_get_host_info returns a string - describing the type of connection in use for the connection - link_identifier, including the server host - name. If link_identifier is omitted, the - last opened connection will be used. - - - - <function>mysql_get_host_info</function> example - + + + mysql_get_host_info + Get MySQL host info + + + Description + + stringmysql_get_host_info + resourcelink_identifier + + + mysql_get_host_info returns a string + describing the type of connection in use for the connection + link_identifier, including the server host + name. If link_identifier is omitted, the + last opened connection will be used. + + + + <function>mysql_get_host_info</function> example + ]]> - - - The above example would produce the following output: - - + + + The above example would produce the following output: + + - - - - - See also - mysql_get_client_info, - mysql_get_proto_info and - mysql_get_server_info. - - - + + + + + See also + mysql_get_client_info, + mysql_get_proto_info and + mysql_get_server_info. + + + + - - - mysql_get_proto_info - Get MySQL protocol info - - - Description - - intmysql_get_proto_info - resourcelink_identifier - - - mysql_get_proto_info returns the protocol - version used by connection - link_identifier. If - link_identifier is omitted, the last opened - connection will be used. - - - - <function>mysql_get_proto_info</function> example - + + + mysql_get_proto_info + Get MySQL protocol info + + + Description + + intmysql_get_proto_info + resourcelink_identifier + + + mysql_get_proto_info returns the protocol + version used by connection + link_identifier. If + link_identifier is omitted, the last opened + connection will be used. + + + + <function>mysql_get_proto_info</function> example + ]]> - - - The above example would produce the following output: - - + + + The above example would produce the following output: + + - - - - - See also - mysql_get_client_info, - mysql_get_host_info and - mysql_get_server_info. - - - + + + + + See also + mysql_get_client_info, + mysql_get_host_info and + mysql_get_server_info. + + + + - - - mysql_get_server_info - Get MySQL server info - - - Description - - stringmysql_get_server_info - resourcelink_identifier - - - mysql_get_server_info returns the server - version used by connection - link_identifier. If - link_identifier is omitted, the last opened - connection will be used. - - - - <function>mysql_get_server_info</function> example - + + + mysql_get_server_info + Get MySQL server info + + + Description + + stringmysql_get_server_info + resourcelink_identifier + + + mysql_get_server_info returns the server + version used by connection + link_identifier. If + link_identifier is omitted, the last opened + connection will be used. + + + + <function>mysql_get_server_info</function> example + ]]> - - - The above example would produce the following output: - - + + + The above example would produce the following output: + + - - - - - See also - mysql_get_client_info, - mysql_get_host_info, - mysql_get_proto_info, and - phpversion. - - - + + + + + See also + mysql_get_client_info, + mysql_get_host_info, + mysql_get_proto_info, and + phpversion. + + + + - - - mysql_info - - Get information about the most recent query - - - - Description - - stringmysql_info - resource - link_identifier - - - - mysql_info returns detailed information about - the last query using the given link_identifier. - If link_identifier isn't specified, the last - opened link is assumed. - - - mysql_info returns a string for all statements - listed below. For everything else, it returns &false;. The string - format depends on the given statement. - - Relevant MySQL Statements - + + + mysql_info + + Get information about the most recent query + + + + Description + + stringmysql_info + resource + link_identifier + + + + mysql_info returns detailed information about + the last query using the given link_identifier. + If link_identifier isn't specified, the last + opened link is assumed. + + + mysql_info returns a string for all statements + listed below. For everything else, it returns &false;. The string + format depends on the given statement. + + Relevant MySQL Statements + - - - The numbers are only for illustrating purpose; their values will - correspond to the query. - - - - mysql_info returns a non-&false; value for the - INSERT ... VALUES statement only if multiple value lists are - specified in the statement. - - - - See also - mysql_affected_rows, - mysql_insert_id, and - mysql_stat. - - - + + + The numbers are only for illustrating purpose; their values will + correspond to the query. + + + + mysql_info returns a non-&false; value for the + INSERT ... VALUES statement only if multiple value lists are + specified in the statement. + + + + See also + mysql_affected_rows, + mysql_insert_id, and + mysql_stat. + + + + - - - mysql_insert_id - - Get the ID generated from the previous INSERT operation - - - - Description - - intmysql_insert_id - resource - link_identifier - - - - mysql_insert_id returns the ID generated for - an AUTO_INCREMENT column by the previous INSERT query using the - given link_identifier. If - link_identifier isn't specified, the last - opened link is assumed. - - - mysql_insert_id returns 0 if the previous - query does not generate an AUTO_INCREMENT value. If you need to - save the value for later, be sure to call - mysql_insert_id immediately after the - query that generates the value. - - - - The value of the MySQL SQL function - LAST_INSERT_ID() always contains the most - recently generated AUTO_INCREMENT value, and is not reset - between queries. - - - - - mysql_insert_id converts the return type of - the native MySQL C API function - mysql_insert_id() to a type of - long (named int in PHP). - If your AUTO_INCREMENT column has a column type of BIGINT, - the value returned by mysql_insert_id - will be incorrect. Instead, use the internal MySQL SQL function - LAST_INSERT_ID() in an SQL query. - - - - - <function>mysql_insert_id</function> example - + + + mysql_insert_id + + Get the ID generated from the previous INSERT operation + + + + Description + + intmysql_insert_id + resource + link_identifier + + + + mysql_insert_id returns the ID generated for + an AUTO_INCREMENT column by the previous INSERT query using the + given link_identifier. If + link_identifier isn't specified, the last + opened link is assumed. + + + mysql_insert_id returns 0 if the previous + query does not generate an AUTO_INCREMENT value. If you need to + save the value for later, be sure to call + mysql_insert_id immediately after the + query that generates the value. + + + + The value of the MySQL SQL function + LAST_INSERT_ID() always contains the most + recently generated AUTO_INCREMENT value, and is not reset + between queries. + + + + + mysql_insert_id converts the return type of + the native MySQL C API function + mysql_insert_id() to a type of + long (named int in PHP). + If your AUTO_INCREMENT column has a column type of BIGINT, + the value returned by mysql_insert_id + will be incorrect. Instead, use the internal MySQL SQL function + LAST_INSERT_ID() in an SQL query. + + + + + <function>mysql_insert_id</function> example + ]]> - - - - - See also - mysql_query and - mysql_info. - - - + + + + + See also + mysql_query and + mysql_info. + + + + - - - mysql_list_dbs - - List databases available on a MySQL server - - - - Description - - resourcemysql_list_dbs - resource - link_identifier - - - - mysql_list_dbs will return a result pointer - containing the databases available from the current mysql - daemon. Use the mysql_tablename function to - traverse this result pointer, or any function for result tables, - such as mysql_fetch_array. - - - - <function>mysql_list_dbs</function> example - + + + mysql_list_dbs + + List databases available on a MySQL server + + + + Description + + resourcemysql_list_dbs + resource + link_identifier + + + + mysql_list_dbs will return a result pointer + containing the databases available from the current mysql + daemon. Use the mysql_tablename function to + traverse this result pointer, or any function for result tables, + such as mysql_fetch_array. + + + + <function>mysql_list_dbs</function> example + Database . "\n"; + echo $row->Database . "\n"; } ?> ]]> - - - The above example would produce the following output: - - + + + The above example would produce the following output: + + - - - - - - The above code would just as easily work with - mysql_fetch_row or other similar functions. - - - - For downward compatibility mysql_listdbs can - also be used. This is deprecated however. - - - See also - mysql_db_name, and - mysql_select_db. - - - + + + + + + The above code would just as easily work with + mysql_fetch_row or other similar functions. + + + + For downward compatibility mysql_listdbs can + also be used. This is deprecated however. + + + See also + mysql_db_name, and + mysql_select_db. + + + + - - - mysql_list_fields - List MySQL table fields - - - Description - - resourcemysql_list_fields - stringdatabase_name - stringtable_name - resource - link_identifier - - - - - The function mysql_list_fields is deprecated. It - is preferable to use mysql_query to issue a - SQL SHOW COLUMNS FROM table [LIKE 'name'] Statement instead. - - - - mysql_list_fields retrieves information - about the given table name. Arguments are the database and - the table name. A result pointer is returned which can be used - with mysql_field_flags, - mysql_field_len, - mysql_field_name, and - mysql_field_type. - - - - Alternate to deprecated <function>mysql_list_fields</function> - + + + mysql_list_fields + List MySQL table fields + + + Description + + resourcemysql_list_fields + stringdatabase_name + stringtable_name + resource + link_identifier + + + + + The function mysql_list_fields is deprecated. It + is preferable to use mysql_query to issue a + SQL SHOW COLUMNS FROM table [LIKE 'name'] Statement instead. + + + + mysql_list_fields retrieves information + about the given table name. Arguments are the database and + the table name. A result pointer is returned which can be used + with mysql_field_flags, + mysql_field_len, + mysql_field_name, and + mysql_field_type. + + + + Alternate to deprecated <function>mysql_list_fields</function> + 0) { } ?> ]]> - - - The above example would produce output similar to: - - + + + The above example would produce output similar to: + + id [Type] => int(7) - [Null] => + [Null] => [Key] => PRI [Default] => [Extra] => auto_increment @@ -75,20 +75,20 @@ Array [Extra] => ) ]]> - - - - - For downward compatibility mysql_listfields - can also be used. This is deprecated however. - - - See also - mysql_field_flags and - mysql_info. - - - + + + + + For downward compatibility mysql_listfields + can also be used. This is deprecated however. + + + See also + mysql_field_flags and + mysql_info. + + + + - - - mysql_list_processes - List MySQL processes - - - Description - - resourcemysql_list_processes - resource - link_identifier - - - - mysql_list_processes returns a result pointer - describing the current server threads. - - - - <function>mysql_list_processes</function> example - + + + mysql_list_processes + List MySQL processes + + + Description + + resourcemysql_list_processes + resource + link_identifier + + + + mysql_list_processes returns a result pointer + describing the current server threads. + + + + <function>mysql_list_processes</function> example + ]]> - - - The above example would produce the following output: - - + + + The above example would produce the following output: + + - - - - - See also - mysql_thread_id and - mysql_stat. - - - + + + + + See also + mysql_thread_id and + mysql_stat. + + + + - - - mysql_list_tables - List tables in a MySQL database - - - Description - - resourcemysql_list_tables - stringdatabase - resource - link_identifier - - - - mysql_list_tables takes a database name and - returns a result pointer much like the - mysql_query function. - Use the mysql_tablename function to - traverse this result pointer, or any function for result tables, - such as mysql_fetch_array. - - - The database parameter is the name of the - database to retrieve the list of tables from. Upon failure, - mysql_list_tables returns &false;. - - - For downward compatibility, the function alias named - mysql_listtables can be used. This is - deprecated however and is not recommended. - - - - The function mysql_list_tables is deprecated. It - is preferable to use mysql_query to issue a - SQL SHOW TABLES [FROM db_name] [LIKE 'pattern'] statement instead. - - - - - <function>mysql_list_tables</function> alternative example - + + + mysql_list_tables + List tables in a MySQL database + + + Description + + resourcemysql_list_tables + stringdatabase + resource + link_identifier + + + + mysql_list_tables takes a database name and + returns a result pointer much like the + mysql_query function. + Use the mysql_tablename function to + traverse this result pointer, or any function for result tables, + such as mysql_fetch_array. + + + The database parameter is the name of the + database to retrieve the list of tables from. Upon failure, + mysql_list_tables returns &false;. + + + For downward compatibility, the function alias named + mysql_listtables can be used. This is + deprecated however and is not recommended. + + + + The function mysql_list_tables is deprecated. It + is preferable to use mysql_query to issue a + SQL SHOW TABLES [FROM db_name] [LIKE 'pattern'] statement instead. + + + + + <function>mysql_list_tables</function> alternative example + ]]> - - - - - See also - mysql_list_dbs and - mysql_tablename. - - - + + + + + See also + mysql_list_dbs and + mysql_tablename. + + + + - - - mysql_num_fields - Get number of fields in result - - - Description - - intmysql_num_fields - resourceresult - - - mysql_num_fields returns the number of - fields in the result set result. - - - - A <function>mysql_num_fields</function> example - + + + mysql_num_fields + Get number of fields in result + + + Description + + intmysql_num_fields + resourceresult + + + mysql_num_fields returns the number of + fields in the result set result. + + + + A <function>mysql_num_fields</function> example + ]]> - - - - - For downward compatibility mysql_numfields - can also be used. This is deprecated however. - - - See also - mysql_select_db, - mysql_query, - mysql_fetch_field and - mysql_num_rows. - - - + + + + + For downward compatibility mysql_numfields + can also be used. This is deprecated however. + + + See also + mysql_select_db, + mysql_query, + mysql_fetch_field and + mysql_num_rows. + + + + - - - mysql_num_rows - Get number of rows in result - - - Description - - intmysql_num_rows - resourceresult - - - mysql_num_rows returns the number of rows in - a result set. This command is only valid for SELECT statements. - To retrieve the number of rows affected by a INSERT, UPDATE or - DELETE query, use mysql_affected_rows. - - <function>mysql_num_rows</function> example - + + + mysql_num_rows + Get number of rows in result + + + Description + + intmysql_num_rows + resourceresult + + + mysql_num_rows returns the number of rows in + a result set. This command is only valid for SELECT statements. + To retrieve the number of rows affected by a INSERT, UPDATE or + DELETE query, use mysql_affected_rows. + + <function>mysql_num_rows</function> example + ]]> - - - - - - If you use mysql_unbuffered_query, - mysql_num_rows will not return the - correct value until all the rows in the result set have been - retrieved. - - - - See also - mysql_affected_rows, - mysql_connect, - mysql_data_seek, - mysql_select_db and - mysql_query. - - - For downward compatibility mysql_numrows can - also be used. This is deprecated however. - - - + + + + + + If you use mysql_unbuffered_query, + mysql_num_rows will not return the + correct value until all the rows in the result set have been + retrieved. + + + + See also + mysql_affected_rows, + mysql_connect, + mysql_data_seek, + mysql_select_db and + mysql_query. + + + For downward compatibility mysql_numrows can + also be used. This is deprecated however. + + + + - - - mysql_pconnect - - Open a persistent connection to a MySQL server - - - - Description - - resourcemysql_pconnect - stringserver - stringusername - stringpassword - intclient_flags - + + + mysql_pconnect + + Open a persistent connection to a MySQL server + + + + Description + + resourcemysql_pconnect + stringserver + stringusername + stringpassword + intclient_flags + + + Returns a positive MySQL persistent link identifier on success, + or &false; on error. + + + mysql_pconnect establishes a connection + to a MySQL server. The following defaults are assumed for + missing optional parameters: server = + 'localhost:3306', username = name of the + user that owns the server process and + password = empty password. + The client_flags + parameter can be a combination of the constants + MYSQL_CLIENT_COMPRESS, MYSQL_CLIENT_IGNORE_SPACE or + MYSQL_CLIENT_INTERACTIVE. + + + The server parameter can also include a port + number. e.g. "hostname:port" or a path to a socket + e.g. ":/path/to/socket" for the localhost. + - Returns a positive MySQL persistent link identifier on success, - or &false; on error. + Support for ":port" was added in 3.0B4. - mysql_pconnect establishes a connection - to a MySQL server. The following defaults are assumed for - missing optional parameters: server = - 'localhost:3306', username = name of the - user that owns the server process and - password = empty password. - The client_flags - parameter can be a combination of the constants - MYSQL_CLIENT_COMPRESS, MYSQL_CLIENT_IGNORE_SPACE or - MYSQL_CLIENT_INTERACTIVE. - - - The server parameter can also include a port - number. e.g. "hostname:port" or a path to a socket - e.g. ":/path/to/socket" for the localhost. - - - Support for ":port" was added in 3.0B4. - - - Support for the ":/path/to/socket" was added in - 3.0.10. - - + Support for the ":/path/to/socket" was added in + 3.0.10. + + - - - mysql_pconnect acts very much like - mysql_connect with two major differences. - - - First, when connecting, the function would first try to find a - (persistent) link that's already open with the same host, - username and password. If one is found, an identifier for it - will be returned instead of opening a new connection. - - - Second, the connection to the SQL server will not be closed when - the execution of the script ends. Instead, the link will remain - open for future use (mysql_close will not - close links established by mysql_pconnect). - - - The optional client_flags parameter became - available in PHP 4.3.0. - - - This type of link is therefore called 'persistent'. - - - - Note, that these kind of links only work if you are using - a module version of PHP. See the - Persistent - Database Connections section for more information. - - - - - Using persistent connections can require a bit of tuning of your Apache - and MySQL configurations to ensure that you do not exceed the number of - connections allowed by MySQL. - - - - + + + mysql_pconnect acts very much like + mysql_connect with two major differences. + + + First, when connecting, the function would first try to find a + (persistent) link that's already open with the same host, + username and password. If one is found, an identifier for it + will be returned instead of opening a new connection. + + + Second, the connection to the SQL server will not be closed when + the execution of the script ends. Instead, the link will remain + open for future use (mysql_close will not + close links established by mysql_pconnect). + + + The optional client_flags parameter became + available in PHP 4.3.0. + + + This type of link is therefore called 'persistent'. + + + + Note, that these kind of links only work if you are using + a module version of PHP. See the + Persistent + Database Connections section for more information. + + + + + Using persistent connections can require a bit of tuning of your Apache + and MySQL configurations to ensure that you do not exceed the number of + connections allowed by MySQL. + + + + + - - - mysql_ping - Ping a server connection or reconnect if there is no connection - - - Description - - boolmysql_ping - resource - link_identifier - - - - mysql_ping checks whether or not the connection to - the server is working. If it has gone down, an automatic reconnection is - attempted. This function can be used by scripts that remain idle for a - long while, to check whether or not the server has closed the connection - and reconnect if necessary. - mysql_ping returns &true; if the connection to the - server is working, otherwise &false;. - - - - A <function>mysql_ping</function> example - + + + mysql_ping + Ping a server connection or reconnect if there is no connection + + + Description + + boolmysql_ping + resource + link_identifier + + + + mysql_ping checks whether or not the connection to + the server is working. If it has gone down, an automatic reconnection is + attempted. This function can be used by scripts that remain idle for a + long while, to check whether or not the server has closed the connection + and reconnect if necessary. + mysql_ping returns &true; if the connection to the + server is working, otherwise &false;. + + + + A <function>mysql_ping</function> example + ]]> - - - - - See also - mysql_thread_id and - mysql_list_processes. - - - + + + + + See also + mysql_thread_id and + mysql_list_processes. + + + + - - - mysql_real_escape_string - - Escapes special characters in a string for use in a SQL statement - - - - Description - - stringmysql_real_escape_string - stringunescaped_string - resourcelink_identifier - - - - - unescaped_string - The string to escape - - - - link_identifier (optional) - The mysql connection resource - - - - - This function will escape special characters in the - unescaped_string, taking into account the current - character set of the connection so that it is safe to place it in a - mysql_query. If binary data is to be inserted, this function - must be used. - - - - A MySQL connection is required before using - mysql_real_escape_string otherwise an error of - level E_WARNING is generated, and &false; is - returned. If link_identifier isn't defined, the - last MySQL connection is used. - - - - mysql_real_escape_string calls MySQL's library function - mysql_escape_string, which prepends backslashes to the following characters: - NULL, \x00, \n, - \r, \, ', - " and \x1a. - - - - Simple <function>mysql_real_escape_string</function> example - + + + mysql_real_escape_string + + Escapes special characters in a string for use in a SQL statement + + + + Description + + stringmysql_real_escape_string + stringunescaped_string + resourcelink_identifier + + + + + unescaped_string + The string to escape + + + + link_identifier (optional) + The mysql connection resource + + + + + This function will escape special characters in the + unescaped_string, taking into account the current + character set of the connection so that it is safe to place it in a + mysql_query. If binary data is to be inserted, this function + must be used. + + + + A MySQL connection is required before using + mysql_real_escape_string otherwise an error of + level E_WARNING is generated, and &false; is + returned. If link_identifier isn't defined, the + last MySQL connection is used. + + + + mysql_real_escape_string calls MySQL's library function + mysql_escape_string, which prepends backslashes to the following characters: + NULL, \x00, \n, + \r, \, ', + " and \x1a. + + + + Simple <function>mysql_real_escape_string</function> example + ]]> - - - - - This function must always (with few exceptions) be used to make data - safe before sending a query to MySQL. - - - - If magic_quotes_gpc is enabled, - first apply stripslashes to the data. Using this function - on data which has already been escaped will escape the data twice. - - - - If this function is not used to escape data, the query is vulnerable to - SQL Injection Attacks. - - - - An example SQL Injection Attack - + + + + + This function must always (with few exceptions) be used to make data + safe before sending a query to MySQL. + + + + If magic_quotes_gpc is enabled, + first apply stripslashes to the data. Using this function + on data which has already been escaped will escape the data twice. + + + + If this function is not used to escape data, the query is vulnerable to + SQL Injection Attacks. + + + + An example SQL Injection Attack + ]]> - - - The query sent to MySQL: - - + + + The query sent to MySQL: + + - - - This would allow anyone to log in without a valid password. - - - + - - A "Best Practice" query - - Using mysql_real_escape_string around each variable - prevents SQL Injection. This example demonstrates the "best practice" - method for querying a database, independent of the - Magic Quotes setting. - - + This would allow anyone to log in without a valid password. + + + + + + A "Best Practice" query + + Using mysql_real_escape_string around each variable + prevents SQL Injection. This example demonstrates the "best practice" + method for querying a database, independent of the + Magic Quotes setting. + + ]]> - - - The query will now execute correctly, and SQL Injection attacks will not work. - - - - - - mysql_real_escape_string does not escape - % and _. These are wildcards in - MySQL if combined with LIKE, GRANT, - or REVOKE. - - + - See also - mysql_client_encoding, - addslashes, - stripslashes, - the magic_quotes_gpc, - and the - magic_quotes_runtime - directive. + The query will now execute correctly, and SQL Injection attacks will not work. - - + + + + + mysql_real_escape_string does not escape + % and _. These are wildcards in + MySQL if combined with LIKE, GRANT, + or REVOKE. + + + + See also + mysql_client_encoding, + addslashes, + stripslashes, + the magic_quotes_gpc, + and the + magic_quotes_runtime + directive. + + + + - - - mysql_result - Get result data - - - Description - - mixedmysql_result - resourceresult - introw - mixed - field - - - - mysql_result returns the contents of one - cell from a MySQL result set. The field argument can be the - field's offset, or the field's name, or the field's table dot - field name (tablename.fieldname). If the column name has been - aliased ('select foo as bar from...'), use the alias instead of - the column name. - - - When working on large result sets, you should consider using one - of the functions that fetch an entire row (specified below). As - these functions return the contents of multiple cells in one - function call, they're MUCH quicker than - mysql_result. Also, note that specifying a - numeric offset for the field argument is much quicker than - specifying a fieldname or tablename.fieldname argument. - - - Calls to mysql_result should not be mixed - with calls to other functions that deal with the result set. - - - - <function>mysql_result</function> example - + + + mysql_result + Get result data + + + Description + + mixedmysql_result + resourceresult + introw + mixed + field + + + + mysql_result returns the contents of one + cell from a MySQL result set. The field argument can be the + field's offset, or the field's name, or the field's table dot + field name (tablename.fieldname). If the column name has been + aliased ('select foo as bar from...'), use the alias instead of + the column name. + + + When working on large result sets, you should consider using one + of the functions that fetch an entire row (specified below). As + these functions return the contents of multiple cells in one + function call, they're MUCH quicker than + mysql_result. Also, note that specifying a + numeric offset for the field argument is much quicker than + specifying a fieldname or tablename.fieldname argument. + + + Calls to mysql_result should not be mixed + with calls to other functions that deal with the result set. + + + + <function>mysql_result</function> example + ]]> - - - - - Recommended high-performance alternatives : - mysql_fetch_row, - mysql_fetch_array, - mysql_fetch_assoc and - mysql_fetch_object. - - - + + + + + Recommended high-performance alternatives : + mysql_fetch_row, + mysql_fetch_array, + mysql_fetch_assoc and + mysql_fetch_object. + + + + - - - mysql_select_db - Select a MySQL database - - - Description - - boolmysql_select_db - stringdatabase_name - resource - link_identifier - - - - &return.success; - - - mysql_select_db sets the current active - database on the server that's associated with the specified link - identifier. If no link identifier is specified, the last opened - link is assumed. If no link is open, the function will try to - establish a link as if mysql_connect was - called without arguments, and use it. - - - Every subsequent call to mysql_query will be - made on the active database. - - - - <function>mysql_select_db</function> example - + + + mysql_select_db + Select a MySQL database + + + Description + + boolmysql_select_db + stringdatabase_name + resource + link_identifier + + + + &return.success; + + + mysql_select_db sets the current active + database on the server that's associated with the specified link + identifier. If no link identifier is specified, the last opened + link is assumed. If no link is open, the function will try to + establish a link as if mysql_connect was + called without arguments, and use it. + + + Every subsequent call to mysql_query will be + made on the active database. + + + + <function>mysql_select_db</function> example + ]]> - - - - - See also - mysql_connect, - mysql_pconnect and - mysql_query. - - - For downward compatibility mysql_selectdb - can also be used. This is deprecated however. - - - + + + + + See also + mysql_connect, + mysql_pconnect and + mysql_query. + + + For downward compatibility mysql_selectdb + can also be used. This is deprecated however. + + + + - - - mysql_tablename - Get table name of field - - - Description - - stringmysql_tablename - resourceresult - inti - - - mysql_tablename takes a result pointer - returned by the mysql_list_tables function - as well as an integer index and returns the name of a table. The - mysql_num_rows function may be used to - determine the number of tables in the result pointer. - Use the mysql_tablename function to - traverse this result pointer, or any function for result tables, - such as mysql_fetch_array. - - <function>mysql_tablename</function> example - + + + mysql_tablename + Get table name of field + + + Description + + stringmysql_tablename + resourceresult + inti + + + mysql_tablename takes a result pointer + returned by the mysql_list_tables function + as well as an integer index and returns the name of a table. The + mysql_num_rows function may be used to + determine the number of tables in the result pointer. + Use the mysql_tablename function to + traverse this result pointer, or any function for result tables, + such as mysql_fetch_array. + + <function>mysql_tablename</function> example + ]]> - - - - - See also - mysql_list_tables, - mysql_field_table, and - mysql_db_name. - - - + + + + + See also + mysql_list_tables, + mysql_field_table, and + mysql_db_name. + + + + - - - mysql_thread_id - Return the current thread ID - - - Description - - intmysql_thread_id - resourcelink_identifier - - - mysql_thread_id returns the current thread ID. If - the connection is lost and you reconnect with - mysql_ping, the thread ID will change. This means - you should not get the thread ID and store it for later. You should get - it when you need it. - - - - <function>mysql_thread_id</function> example - + + + mysql_thread_id + Return the current thread ID + + + Description + + intmysql_thread_id + resourcelink_identifier + + + mysql_thread_id returns the current thread ID. If + the connection is lost and you reconnect with + mysql_ping, the thread ID will change. This means + you should not get the thread ID and store it for later. You should get + it when you need it. + + + + <function>mysql_thread_id</function> example + ]]> - - - The above example would produce the following output: - - + + + The above example would produce the following output: + + - - - - - See also - mysql_ping and - mysql_list_processes. - - - + + + + + See also + mysql_ping and + mysql_list_processes. + + + + - - - mysql_unbuffered_query - - Send an SQL query to MySQL, without fetching and buffering the - result rows - - - - Description - - resourcemysql_unbuffered_query - stringquery - resourcelink_identifier - - - mysql_unbuffered_query sends a SQL query - query to MySQL, without fetching and - buffering the result rows automatically, as - mysql_query does. On the one hand, this - saves a considerable amount of memory with SQL queries that - produce large result sets. On the other hand, you can start - working on the result set immediately after the first row has - been retrieved: you don't have to wait until the complete SQL - query has been performed. When using multiple DB-connects, you - have to specify the optional parameter - link_identifier. - - - - The benefits of mysql_unbuffered_query come - at a cost: You cannot use mysql_num_rows and - mysql_data_seek on a result set returned from - mysql_unbuffered_query. You also have to - fetch all result rows from an unbuffered SQL query, before you - can send a new SQL query to MySQL. - - - - See also mysql_query. - - - + + + mysql_unbuffered_query + + Send an SQL query to MySQL, without fetching and buffering the + result rows + + + + Description + + resourcemysql_unbuffered_query + stringquery + resourcelink_identifier + + + mysql_unbuffered_query sends a SQL query + query to MySQL, without fetching and + buffering the result rows automatically, as + mysql_query does. On the one hand, this + saves a considerable amount of memory with SQL queries that + produce large result sets. On the other hand, you can start + working on the result set immediately after the first row has + been retrieved: you don't have to wait until the complete SQL + query has been performed. When using multiple DB-connects, you + have to specify the optional parameter + link_identifier. + + + + The benefits of mysql_unbuffered_query come + at a cost: You cannot use mysql_num_rows and + mysql_data_seek on a result set returned from + mysql_unbuffered_query. You also have to + fetch all result rows from an unbuffered SQL query, before you + can send a new SQL query to MySQL. + + + + See also mysql_query. + + +