diff --git a/functions/mysql.xml b/functions/mysql.xml index 91dd0af208..f7638ccee9 100644 --- a/functions/mysql.xml +++ b/functions/mysql.xml @@ -1,7 +1,7 @@ - + - MySQL functions + MySQL Functions MySQL @@ -46,12 +46,12 @@ // printing HTML result print "<table>\n"; - while($line = mysql_fetch_array($result)){ - print "\t<tr>\n"; - while(list($col_name, $col_value) = each($line)){ - print "\t\t<td>$col_value</td>\n"; - } - print "\t</tr>\n"; + while ($line = mysql_fetch_array($result)) { + print "\t<tr>\n"; + while(list($col_name, $col_value) = each($line)) { + print "\t\t<td>$col_value</td>\n"; + } + print "\t</tr>\n"; } print "</table>\n"; @@ -155,13 +155,18 @@ 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, - the current connected user stays active. + the current connected user stays active. + - - This function was introduced in PHP 3.0.13 and - requires MySQL 3.23.3 or higher. - + + + + + This function was introduced in PHP 3.0.13 and requires MySQL + 3.23.3 or higher. + + @@ -275,8 +280,8 @@ PHP 3.0.10. - You can suppress the error message on failure by prepending '@' - to the function name. + You can suppress the error message on failure by prepending '@' + to the function name. @@ -295,17 +300,15 @@ MySQL connect example <?php - $link = mysql_connect ("localhost", "username", "secret") or die ("Could not connect"); print ("Connected successfully"); mysql_close ($link); - ?> See also - mysql_pconnect, and + mysql_pconnect and mysql_close. @@ -385,7 +388,6 @@ Row_number starts at 0. - MySQL data seek example @@ -447,14 +449,12 @@ 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 @@ -473,12 +473,10 @@ while ($i < $cnt) { ?> - For backward compatibility, mysql_dbname is also accepted. This is deprecated, however. - @@ -565,8 +563,10 @@ while ($i < $cnt) { mysql_errno - Returns the numerical value of the error message from previous - MySQL operation + + Returns the numerical value of the error message from previous + MySQL operation + Description @@ -615,8 +615,10 @@ echo mysql_errno().": ".mysql_error()."<BR>"; mysql_error - Returns the text of the error message from previous - MySQL operation + + Returns the text of the error message from previous MySQL + operation + Description @@ -682,8 +684,8 @@ echo mysql_errno().": ".mysql_error()."<BR>"; - mysql_escape_string does not escape % - and _. + mysql_escape_string does not escape + % and _. @@ -743,7 +745,8 @@ select t1.f1 as foo t2.f1 as bar from t1, t2 For further details, see also - mysql_fetch_row and mysql_fetch_assoc. + mysql_fetch_row and + mysql_fetch_assoc. <function>mysql_fetch_array</function> example @@ -783,7 +786,7 @@ mysql_free_result ($result); 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_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 @@ -792,9 +795,10 @@ mysql_free_result ($result); 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. + 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 @@ -804,7 +808,8 @@ mysql_free_result ($result); For further details, see also - mysql_fetch_row and mysql_fetch_array. + mysql_fetch_row and + mysql_fetch_array. <function>mysql_fetch_assoc</function> @@ -823,7 +828,7 @@ mysql_free_result ($result); - + mysql_fetch_field @@ -1449,7 +1454,7 @@ $link = mysql_connect('localhost', 'myname', 'secret'); $db_list = mysql_list_dbs($link); while ($row = mysql_fetch_object($db_list)) { - echo $row->Database . "\n"; + echo $row->Database . "\n"; } @@ -1475,7 +1480,9 @@ database3 For downward compatibility mysql_listdbs can also be used. - See also mysql_db_name + + See also mysql_db_name. + @@ -1526,7 +1533,7 @@ $fields = mysql_list_fields("database1", "table1", $link); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { - echo mysql_field_name($fields, $i) . "\n";; + echo mysql_field_name($fields, $i) . "\n";; } @@ -1654,7 +1661,7 @@ echo "$num_rows Rows\n"; See also: mysql_affected_rows, mysql_connect, - mysql_select_db and + mysql_select_db, and mysql_query. @@ -1845,7 +1852,10 @@ $result = mysql_query ("SELECT my_col FROM my_tbl") mysql_unbuffered_query - Send an SQL query to MySQL, without fetching and buffering the result rows + + Send an SQL query to MySQL, without fetching and buffering the + result rows + Description @@ -1856,26 +1866,29 @@ $result = mysql_query ("SELECT my_col FROM my_tbl") resource link_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. + 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 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. + The benefits of mysql_unbuffered_query come + at a cost: You cannot use mysql_num_rows 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. @@ -2027,12 +2040,12 @@ while ($i < mysql_num_rows ($result)) { string mysql_get_client_info - + - mysql_get_client_info returns a string that represents - the client library version. + mysql_get_client_info returns a string that + represents the client library version. mysql_get_client_info was added in PHP 4.0.5. @@ -2050,15 +2063,17 @@ while ($i < mysql_num_rows ($result)) { string mysql_get_host_info - resource link_identifier + resource + link_identifier + - mysql_get_host_info returns a string + 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 omited, the last opened - connection will be used. + link_identifier, including the server host + name. If link_identifier is omited, the + last opened connection will be used. mysql_get_host_info was added in PHP 4.0.5. @@ -2076,13 +2091,16 @@ while ($i < mysql_num_rows ($result)) { int mysql_get_proto_info - resource link_identifier + resource + link_identifier + - mysql_get_proto_info returns the protocol version - used by connection link_identifier. - If link_identifier is omited, the last opened + mysql_get_proto_info returns the protocol + version used by connection + link_identifier. If + link_identifier is omited, the last opened connection will be used. @@ -2101,13 +2119,16 @@ while ($i < mysql_num_rows ($result)) { int mysql_get_server_info - resource link_identifier + resource + link_identifier + - mysql_get_server_info returns the server version - used by connection link_identifier. - If link_identifier is omited, the last opened + mysql_get_server_info returns the server + version used by connection + link_identifier. If + link_identifier is omited, the last opened connection will be used.