From 303622dff96ca8479bfa7fdc7900c4a43641c007 Mon Sep 17 00:00:00 2001 From: James Moore Date: Mon, 6 Nov 2000 23:45:56 +0000 Subject: [PATCH] Fixing style changes made by editor git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@35397 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/mysql.xml | 973 +++++++++++++++----------------------------- 1 file changed, 324 insertions(+), 649 deletions(-) diff --git a/functions/mysql.xml b/functions/mysql.xml index f1c13378f8..c81c2f7a72 100644 --- a/functions/mysql.xml +++ b/functions/mysql.xml @@ -3,26 +3,17 @@ MySQL - These functions allow you to access MySQL database -servers. In - order to have these functions available, you must -compile php + These functions allow you to access MySQL database servers. In + order to have these functions available, you must compile php with mysql support by using the - option. -If you - use this option without specifying the path to mysql, -php will - use the built-in mysql client libraries. Users who run -other - applications that use mysql (for example, running php3 -and php4 - as concurrent apache modules, or auth-mysql) should -always + option. If you + use this option without specifying the path to mysql, php will + use the built-in mysql client libraries. Users who run other + applications that use mysql (for example, running php3 and php4 + as concurrent apache modules, or auth-mysql) should always specify the path to mysql: - . - This will force php to use the client libraries -installed by + . + This will force php to use the client libraries installed by mysql, avoiding any conflicts. @@ -39,16 +30,14 @@ installed by mysql_affected_rows - Get number of affected rows in previous -MySQL + Get number of affected rows in previous MySQL operation Description - int -mysql_affected_rows + int mysql_affected_rows int link_identifier @@ -57,29 +46,20 @@ MySQL - mysql_affected_rows returns the -number of - rows affected by the last INSERT, UPDATE or DELETE -query on the - server associated with the specified link identifier. -If the - link identifier isn't specified, the last opened link -is assumed. + mysql_affected_rows returns the number of + rows affected by the last INSERT, UPDATE or DELETE query on the + server associated with the specified link identifier. If the + link identifier isn't specified, the last opened link is assumed. - 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 + 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. - This command is not effective for SELECT statements, -only on - statements which modify records. To retrieve the number -of rows - returned from a SELECT, use -mysql_num_rows. + This command is not effective for SELECT statements, only on + statements which modify records. To retrieve the number of rows + returned from a SELECT, use mysql_num_rows. @@ -95,12 +75,9 @@ of rows Description - int -mysql_change_user - string -user - string -password + int mysql_change_user + string user + string password string database @@ -114,18 +91,13 @@ of rows - mysql_change_user changes the -logged in user - of the current active connection, or the connection -given by the + mysql_change_user changes the logged in user + of the current active connection, or the connection given by the optional parameter link_identifier. If a database is - specified, this will default or current database after -the user - has been changed. If the new user and password -authorization fails, + specified, this will default or current database after the user + has been changed. If the new user and password authorization fails, the current connected user stays active. - This function was introduced in PHP 3.0.13 -and + This function was introduced in PHP 3.0.13 and requires MySQL 3.23.3 or higher. @@ -140,12 +112,10 @@ and Description - int -mysql_close + int mysql_close int - link_identifier - + link_identifier @@ -153,25 +123,19 @@ and Returns: true on success, false on error. - mysql_close closes the -connection to - the MySQL server that's associated with the specified -link - identifier. If link_identifier -isn't + 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 + Using mysql_close isn't usually necessary, + as non-persistent open links are automatically closed at the end of the script's execution. - mysql_close will not close -persistent links + mysql_close will not close persistent links created by mysql_pconnect. @@ -196,15 +160,13 @@ persistent links mysql_connect - Open a connection to a MySQL -Server + Open a connection to a MySQL Server Description - int -mysql_connect + int mysql_connect string hostname @@ -226,26 +188,20 @@ Server - Returns a positive MySQL link identifier on success, or -an error + Returns a positive MySQL link identifier on success, or an error message on failure. - mysql_connect establishes a -connection - to a MySQL server. The following defaults are assumed -for - missing optional parameters: -host:port = - 'localhost:3306', username = -name of the + mysql_connect establishes a connection + to a MySQL server. The following defaults are assumed for + missing optional parameters: host:port = + 'localhost:3306', username = name of the user that owns the server process and password = empty password. The hostname string can also include a port - number. eg. "hostname:port" or a path to a -socket + number. eg. "hostname:port" or a path to a socket eg. ":/path/to/socket" for the localhost. @@ -256,26 +212,20 @@ socket PHP 3.0.10. - You can suppress the error message on failure by -prepending '@' + You can suppress the error message on failure by prepending '@' to the function name. - If a second call is made to -mysql_connect - with the same arguments, no new link will be -established, but - instead, the link identifier of the already opened link -will be + If a second call is made to mysql_connect + with the same arguments, no new link will be established, but + instead, the link identifier of the already opened link will be returned. - The link to the server will be closed as soon as the -execution of - the script ends, unless it's closed earlier by -explicitly calling + The link to the server will be closed as soon as the execution of + the script ends, unless it's closed earlier by explicitly calling mysql_close. @@ -305,10 +255,8 @@ explicitly calling Description - int -mysql_create_db - string database -name + int mysql_create_db + string database name int link_identifier @@ -317,10 +265,8 @@ name - mysql_create_db attempts to create -a new - database on the server associated with the specified -link + mysql_create_db attempts to create a new + database on the server associated with the specified link identifier. @@ -332,15 +278,13 @@ link if (mysql_create_db ("my_db")) { print ("Database created successfully\n"); } else { - printf ("Error creating database: %s\n", mysql_error -()); + printf ("Error creating database: %s\n", mysql_error ()); } ?> - For downwards compatibility -mysql_createdb + For downwards compatibility mysql_createdb can also be used. @@ -358,26 +302,19 @@ link Description - int -mysql_data_seek - int -result_identifier - int -row_number + int mysql_data_seek + int result_identifier + int row_number Returns: true on success, false on failure. - 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. + 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. Row_number starts at 0. @@ -408,8 +345,7 @@ that row. if(!($row = mysql_fetch_object ($result))) continue; - printf ("%s %s<BR>\n", $row->last_name, -$row->first_name); + printf ("%s %s<BR>\n", $row->last_name, $row->first_name); } mysql_free_result ($result); @@ -428,8 +364,7 @@ $row->first_name); Description - int -mysql_db_name + int mysql_db_name int result int row mixed @@ -440,26 +375,22 @@ $row->first_name); - mysql_db_name takes as its first -parameter + 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 + 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 + mysql_error to determine the nature of the error. - <function>Mysql_db_name</function> -example + <function>Mysql_db_name</function> example <?php error_reporting(E_ALL); @@ -478,8 +409,7 @@ while ($i < $cnt) { - For backward compatibility, -mysql_dbname is + For backward compatibility, mysql_dbname is also accepted. This is deprecated, however. @@ -495,12 +425,9 @@ while ($i < $cnt) { Description - int -mysql_db_query - string -database - string -query + int mysql_db_query + string database + string query int link_identifier @@ -509,21 +436,15 @@ while ($i < $cnt) { - Returns: A positive MySQL result identifier to the -query result, + Returns: A positive MySQL result identifier to the query result, or false on error. - 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 + 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 @@ -531,8 +452,7 @@ with no For downwards - compatibility mysql can also be -used. + compatibility mysql can also be used. @@ -546,10 +466,8 @@ used. Description - int -mysql_drop_db - string -database_name + int mysql_drop_db + string database_name int link_identifier @@ -561,17 +479,13 @@ used. Returns: true on success, false on failure. - mysql_drop_db attempts to drop -(remove) an - entire database from the server associated with the -specified + mysql_drop_db attempts to drop (remove) an + entire database from the server associated with the specified link identifier. - See also: mysql_create_db. For -downward - compatibility mysql_dropdb can -also be used. + See also: mysql_create_db. For downward + compatibility mysql_dropdb can also be used. @@ -579,16 +493,14 @@ also be used. mysql_errno - Returns the numerical value of the error -message from previous + Returns the numerical value of the error message from previous MySQL operation Description - int -mysql_errno + int mysql_errno int link_identifier @@ -597,24 +509,17 @@ message from previous - Returns the error number from the last mySQL function, -or + 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 + 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 + mysql_errno), so if you want to use it, + make sure you check the value before calling another mySQL function. @@ -638,16 +543,14 @@ echo mysql_errno().": ".mysql_error()."<BR>"; mysql_error - Returns the text of the error message from -previous + Returns the text of the error message from previous MySQL operation Description - string -mysql_error + string mysql_error int link_identifier @@ -657,23 +560,16 @@ previous Returns the error text from the last mySQL function, or - '' (the empty string) if no error -occurred. + '' (the empty string) if no error occurred. - 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 + 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. + mysql_errno), so if you want to use it, make + sure you check the value before calling another mySQL function. <?php @@ -697,16 +593,14 @@ echo mysql_errno().": ".mysql_error()."<BR>"; mysql_fetch_array - Fetch a result row as an associative array, a numeric -array, or both. + Fetch a result row as an associative array, a numeric array, or both. Description - array -mysql_fetch_array + array mysql_fetch_array int result int @@ -716,26 +610,18 @@ array, or both. - Returns an array that corresponds to the fetched row, -or false + 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. + 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 the numeric index of the -column or + 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 the numeric index of the column or make an alias for the column. @@ -745,32 +631,26 @@ select t1.f1 as foo t2.f1 as bar from t1, t2 An important thing to note is that using - mysql_fetch_array is NOT -significantly - slower than using mysql_fetch_row, -while it + 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 + 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) For further details, see also - mysql_fetch_row and -mysql_fetch_assoc. + mysql_fetch_row and mysql_fetch_assoc. <function>Mysql_fetch_array</function> <?php mysql_connect ($host, $user, $password); -$result = mysql_db_query ("database","select user_id, -fullname from table"); +$result = mysql_db_query ("database","select user_id, fullname from table"); while ($row = mysql_fetch_array ($result)) { echo "user_id: ".$row["user_id"]."<br>\n"; echo "user_id: ".$row[0]."<br>\n"; @@ -795,49 +675,36 @@ mysql_free_result ($result); Description - array -mysql_fetch_assoc + array mysql_fetch_assoc int result - Returns an associative array that corresponds to the -fetched row, + Returns an associative array that corresponds to the fetched row, or false if there are no more rows. - mysql_fetch_assoc is eqivilant 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 + mysql_fetch_assoc is eqivilant 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. + 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 must use -mysql_fetch_array and + 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 mysql_fetch_array and have it return the numeric indices as well. An important thing to note is that using - mysql_fetch_assoc is NOT -significantly - slower than using mysql_fetch_row, -while it + mysql_fetch_assoc is NOT significantly + slower than using mysql_fetch_row, while it provides a significant added value. For further details, see also - mysql_fetch_row and -mysql_fetch_array. + mysql_fetch_row and mysql_fetch_array. <function>Mysql_fetch_assoc</function> @@ -860,16 +727,14 @@ mysql_free_result ($result); mysql_fetch_field - Get column information from a result and return as an -object + Get column information from a result and return as an object Description - object -mysql_fetch_field + object mysql_fetch_field int result int @@ -882,14 +747,10 @@ object 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. + 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: @@ -1009,26 +870,21 @@ mysql_free_result ($result); Description - array -mysql_fetch_lengths + array mysql_fetch_lengths int result - Returns: An array that corresponds to the lengths of -each field - in the last row fetched by -mysql_fetch_row, + 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 + mysql_fetch_lengths stores the lengths of each result column in the last row returned by mysql_fetch_row, mysql_fetch_array, and - mysql_fetch_object in an array, -starting at + mysql_fetch_object in an array, starting at offset 0. @@ -1046,8 +902,7 @@ starting at Description - object -mysql_fetch_object + object mysql_fetch_object int result int @@ -1057,41 +912,32 @@ starting at - Returns an object with properties that correspond to -the fetched + 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 + 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). - The optional argument -result_type is a - constant and can take the following values: -MYSQL_ASSOC, + The optional argument result_type is a + constant and can take the following values: MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH. Speed-wise, the function is identical to - mysql_fetch_array, and almost as -quick as + mysql_fetch_array, and almost as quick as mysql_fetch_row (the difference is insignificant). - <function>mysql_fetch_object</function> -example + <function>mysql_fetch_object</function> example <?php mysql_connect ($host, $user, $password); -$result = mysql_db_query ("database", "select * from -table"); +$result = mysql_db_query ("database", "select * from table"); while ($row = mysql_fetch_object ($result)) { echo $row->user_id; echo $row->fullname; @@ -1111,37 +957,29 @@ mysql_free_result ($result); mysql_fetch_row - Get a result row as an enumerated -array + Get a result row as an enumerated array Description - array -mysql_fetch_row + array mysql_fetch_row int result - Returns: An array that corresponds to the fetched row, -or false + Returns: An array that corresponds to the fetched row, or false if there are no more rows. - 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 + 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 + Subsequent call to mysql_fetch_row would + return the next row in the result set, or false if there are no more rows. @@ -1158,41 +996,31 @@ there are no mysql_field_flags - Get the flags associated with the specified field in a -result + Get the flags associated with the specified field in a result Description - string -mysql_field_flags + string mysql_field_flags int result - int -field_offset + int field_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 + 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", + 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", "timestamp". - For downward compatibility -mysql_fieldflags + For downward compatibility mysql_fieldflags can also be used. @@ -1209,20 +1037,15 @@ of MySQL Description - string -mysql_field_name + string mysql_field_name int result - int -field_index + int field_index - mysql_field_name returns the name -of the - specified field index. result -must be a - valid result identifier and -field_index is + 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. @@ -1230,23 +1053,20 @@ must be a field_index starts at 0. - e.g. The index of the third field would actually be 2, -the index + e.g. The index of the third field would actually be 2, the index of the fourth field would be 3 and so on. - <function>mysql_field_name</function> -example + <function>mysql_field_name</function> example // The users table consists of three fields: // user_id // username // password. -$res = mysql_db_query("users", "select * from users", -$link); +$res = mysql_db_query("users", "select * from users", $link); echo mysql_field_name($res, 0) . "\n"; echo mysql_field_name($res, 2); @@ -1263,8 +1083,7 @@ password - For downwards compatibility -mysql_fieldname + For downwards compatibility mysql_fieldname can also be used. @@ -1281,21 +1100,17 @@ password Description - int -mysql_field_len + int mysql_field_len int result - int -field_offset + int field_offset - mysql_field_len returns the length -of the + mysql_field_len returns the length of the specified field. - For downward compatibility -mysql_fieldlen + For downward compatibility mysql_fieldlen can also be used. @@ -1312,18 +1127,14 @@ of the Description - int -mysql_field_seek + int mysql_field_seek int result - int -field_offset + int field_offset - Seeks to the specified field offset. If the next call -to - mysql_fetch_field doesn't include -a field + 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. @@ -1344,21 +1155,17 @@ a field Description - string -mysql_field_table + string mysql_field_table int result - int -field_offset + int field_offset - Returns the name of the table that the specifed field -is + Returns the name of the table that the specifed field is in. - For downward compatibility -mysql_fieldtable + For downward compatibility mysql_fieldtable can also be used. @@ -1375,21 +1182,16 @@ is Description - string -mysql_field_type + string mysql_field_type int result - int -field_offset + int field_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 + 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. @@ -1404,8 +1206,7 @@ $fields = mysql_num_fields ($result); $rows = mysql_num_rows ($result); $i = 0; $table = mysql_field_table ($result, $i); -echo "Your '".$table."' table has ".$fields." fields and -".$rows." records <BR>"; +echo "Your '".$table."' table has ".$fields." fields and ".$rows." records <BR>"; echo "The table has the following fields <BR>"; while ($i < $fields) { $type = mysql_field_type ($result, $i); @@ -1422,8 +1223,7 @@ mysql_close(); - For downward compatibility -mysql_fieldtype + For downward compatibility mysql_fieldtype can also be used. @@ -1438,30 +1238,22 @@ mysql_close(); Description - int -mysql_free_result + int mysql_free_result int result - mysql_free_result will free all -memory - associated with the result identifier -result. + 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. + 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. - For downward compatibility -mysql_freeresult + For downward compatibility mysql_freeresult can also be used. @@ -1478,8 +1270,7 @@ execution. Description - int -mysql_insert_id + int mysql_insert_id int link_identifier @@ -1488,45 +1279,34 @@ execution. - mysql_insert_id returns the ID -generated for - an AUTO_INCREMENT column by the previous INSERT query -using the + 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 + 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() + 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 + 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 + mysql_insert_id converts the return type of the native MySQL C API function mysql_insert_id() to a type of - long. If your AUTO_INCREMENT -column has + long. If your AUTO_INCREMENT column has a column type of BIGINT, the value returned by - mysql_insert_id will be -incorrect. + mysql_insert_id will be incorrect. Instead, use the internal MySQL SQL function LAST_INSERT_ID(). @@ -1545,8 +1325,7 @@ incorrect. Description - int -mysql_list_dbs + int mysql_list_dbs int link_identifier @@ -1555,18 +1334,14 @@ incorrect. - mysql_list_dbs will return a -result pointer - containing the databases available from the current -mysql - daemon. Use the mysql_tablename -function to + 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. - <function>mysql_list_dbs</function> -example + <function>mysql_list_dbs</function> example $link = mysql_connect('localhost', 'myname', 'secret'); $db_list = mysql_list_dbs($link); @@ -1591,13 +1366,11 @@ database3 The above code would just as easily work with - mysql_fetch_row or other similar -functions. + mysql_fetch_row or other similar functions. - For downward compatibility -mysql_listdbs can + For downward compatibility mysql_listdbs can also be used. @@ -1612,12 +1385,9 @@ functions. Description - int -mysql_list_fields - string -database_name - string -table_name + int mysql_list_fields + string database_name + string table_name int link_identifier @@ -1626,32 +1396,24 @@ functions. - mysql_list_fields retrieves -information - about the given tablename. Arguments are the database -name and - the table name. A result pointer is returned which can -be used + mysql_list_fields retrieves information + about the given tablename. Arguments are the database name 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. - A result identifier is a positive integer. The function -returns - -1 if a error occurs. A string describing the error -will be - placed in $phperrmsg, and unless the -function - was called as @mysql() then this -error string + A result identifier is a positive integer. The function returns + -1 if a error occurs. A string describing the error will be + placed in $phperrmsg, and unless the function + was called as @mysql() then this error string will also be printed out. - <function>mysql_list_fields</function> -example + <function>mysql_list_fields</function> example $link = mysql_connect('localhost', 'myname', 'secret'); @@ -1676,8 +1438,7 @@ field3 - For downward compatibility -mysql_listfields + For downward compatibility mysql_listfields can also be used. @@ -1692,10 +1453,8 @@ field3 Description - int -mysql_list_tables - string -database + int mysql_list_tables + string database int link_identifier @@ -1704,17 +1463,14 @@ field3 - mysql_list_tables takes a database -name and + mysql_list_tables takes a database name and returns a result pointer much like the mysql_db_query function. The - mysql_tablename function should be -used to + mysql_tablename function should be used to extract the actual table names from the result pointer. - For downward compatibility -mysql_listtables + For downward compatibility mysql_listtables can also be used. @@ -1729,14 +1485,12 @@ used to Description - int -mysql_num_fields + int mysql_num_fields int result - mysql_num_fields returns the -number of + mysql_num_fields returns the number of fields in a result set. @@ -1746,8 +1500,7 @@ number of mysql_fetch_field, mysql_num_rows. - For downward compatibility -mysql_numfields + For downward compatibility mysql_numfields can also be used. @@ -1762,18 +1515,14 @@ number of Description - int -mysql_num_rows + int mysql_num_rows int result - 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 returned from a INSERT, -UPDATE or + 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 returned from a INSERT, UPDATE or DELETE, use mysql_affected_rows. @@ -1783,12 +1532,9 @@ UPDATE or <?php -$conn = mysql_connect("hostaddress", "username", -"password"); -mysql_select_db("database",$conn); // needed if you have -m,ultiple db's -$Resultfornummembers = mysql_query("SELECT * FROM -Accounts",$conn); +$conn = mysql_connect("hostaddress", "username", "password"); +mysql_select_db("database",$conn); // needed if you have m,ultiple db's +$Resultfornummembers = mysql_query("SELECT * FROM Accounts",$conn); $NumMembers = mysql_num_rows($Resultfornummembers); echo "$NumMembers Members"; ?> @@ -1802,8 +1548,7 @@ echo "$NumMembers Members"; mysql_fetch_row. - For downward compatibility -mysql_numrows can + For downward compatibility mysql_numrows can also be used. @@ -1820,8 +1565,7 @@ echo "$NumMembers Members"; Description - int -mysql_pconnect + int mysql_pconnect string hostname @@ -1839,61 +1583,46 @@ echo "$NumMembers Members"; - Returns: A positive MySQL persistent link identifier on -success, + 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: -host:port = - 'localhost:3306', username = -name of the + mysql_pconnect establishes a connection + to a MySQL server. The following defaults are assumed for + missing optional parameters: host:port = + 'localhost:3306', username = name of the user that owns the server process and password = empty password. The hostname string can also include a port - number. eg. "hostname:port" or a path to a -socket + number. eg. "hostname:port" or a path to a socket eg. ":/path/to/socket" for the localhost. Support for ":port" wass added in 3.0B4. - Support for the ":/path/to/socket" was -added in + Support for the ":/path/to/socket" was added in 3.0.10. mysql_pconnect acts very much like - mysql_connect with two major -differences. + 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 + 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). + 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). This type of links is therefore called 'persistent'. @@ -1910,29 +1639,20 @@ will not Description - int -mysql_query - string -query + int mysql_query + string query int - -link_identifier + link_identifier - mysql_query sends a query to the -currently - active database on the server that's associated with -the + mysql_query sends a query to the currently + active database on the server that's associated with the specified link identifier. If - link_identifier isn't specified, -the last - opened link is assumed. If no link is open, the -function tries - to establish a link as if -mysql_connect was + link_identifier isn't specified, the last + opened link is assumed. If no link is open, the function tries + to establish a link as if mysql_connect was called with no arguments, and use it. @@ -1941,22 +1661,16 @@ function tries - mysql_query returns TRUE -(non-zero) or FALSE - to indicate whether or not the query succeeded. A -return value - of TRUE means that the query was legal and could be -executed by - the server. It does not indicate anything about the -number of - rows affected or returned. It is perfectly possible for -a query + mysql_query returns TRUE (non-zero) or FALSE + to indicate whether or not the query succeeded. A return value + of TRUE means that the query was legal and could be executed by + the server. It does not indicate anything about the number of + rows affected or returned. It is perfectly possible for a query to succeed but affect no rows or return no rows. The following query is syntactically invalid, so - mysql_query fails and returns -FALSE: + mysql_query fails and returns FALSE: <function>mysql_query</function> @@ -1970,8 +1684,7 @@ $result = mysql_query ("SELECT * WHERE 1=1") The following query is semantically invalid if my_col is not a column in the table - my_tbl, so -mysql_query + my_tbl, so mysql_query fails and returns FALSE: <function>mysql_query</function> @@ -1984,35 +1697,25 @@ $result = mysql_query ("SELECT my_col FROM my_tbl") - mysql_query will also fail and -return FALSE - if you don't have permission to access the table(s) -referenced by + mysql_query will also fail and return FALSE + if you don't have permission to access the table(s) referenced by the query. Assuming the query succeeds, you can call - mysql_num_rows to find out how -many rows + mysql_num_rows to find out how many rows were returned for a SELECT statment or - mysql_affected_rows to find out -how many - rows were affected by a DELETE, INSERT, REPLACE, or -UPDATE + mysql_affected_rows to find out how many + rows were affected by a DELETE, INSERT, REPLACE, or UPDATE statement. - For SELECT statements, mysql_query -returns a + For SELECT statements, mysql_query returns a new result identifier that you can pass to - mysql_result. When you are done -with the - result set, you can free the resources associated with -it by - calling mysql_free_result. -Although, the - memory will automatically be freed at the end of the -script's + mysql_result. When you are done with the + result set, you can free the resources associated with it by + calling mysql_free_result. Although, the + memory will automatically be freed at the end of the script's execution. @@ -2035,8 +1738,7 @@ script's Description - mixed -mysql_result + mixed mysql_result int result int row mixed @@ -2047,37 +1749,25 @@ script's - 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's name (fieldname.tablename). If the column name -has been - aliased ('select foo as bar from...'), use the alias -instead of + 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's name (fieldname.tablename). 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 + 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 + 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. + Calls to mysql_result should not be mixed + with calls to other functions that deal with the result set. Recommended high-performance alternatives: @@ -2097,10 +1787,8 @@ set. Description - int -mysql_select_db - string -database_name + int mysql_select_db + string database_name int link_identifier @@ -2112,21 +1800,15 @@ set. Returns: true on success, false on error. - 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 + 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, and use it. - Every subsequent call to -mysql_query will be + Every subsequent call to mysql_query will be made on the active database. See also: @@ -2135,8 +1817,7 @@ try to mysql_query. - For downward compatibility -mysql_selectdb + For downward compatibility mysql_selectdb can also be used. @@ -2151,25 +1832,19 @@ try to Description - string -mysql_tablename + string mysql_tablename int result int i - 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 + 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. - <function>Mysql_tablename</function> -Example + <function>Mysql_tablename</function> Example <?php mysql_connect ("localhost:3306");