From e52a60666ce6343e63574e42b34a26aa2cc0f68c Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Mon, 25 Mar 2002 20:26:03 +0000 Subject: [PATCH] - Fix examples in MySQL - Fix parameters types and reorder sections in uodbc git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@75190 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/mysql.xml | 213 +++++++++++++++--------------- functions/uodbc.xml | 307 +++++++++++++++++++++++++------------------- 2 files changed, 282 insertions(+), 238 deletions(-) diff --git a/functions/mysql.xml b/functions/mysql.xml index bf245470b3..82dceba070 100644 --- a/functions/mysql.xml +++ b/functions/mysql.xml @@ -1,5 +1,5 @@ - + MySQL Functions MySQL @@ -159,38 +159,36 @@ MySQL extension overview example - \n"; - while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { - print "\t\n"; - foreach ($line as $col_value) { - print "\t\t$col_value\n"; - } - print "\t\n"; - } - print "\n"; + /* Printing results in HTML */ + print "\n"; + while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { + print "\t\n"; + foreach ($line as $col_value) { + print "\t\t\n"; + } + print "\t\n"; + } + print "
$col_value
\n"; - // Free resultset - mysql_free_result($result); + /* Free resultset */ + mysql_free_result($result); - // Closing connection - mysql_close($link); - ?> - ]]> + /* Closing connection */ + mysql_close($link); +?> +]]>
@@ -316,7 +314,7 @@ $link = mysql_connect('localhost', 'myname', 'secret'); $charset = mysql_character_set_name($link); printf ("current character set is %s\n", $charset); - +?> ]]> @@ -510,6 +508,7 @@ latin1 =0; $i--) { + /* fetch rows in reverse order */ + for ($i = mysql_num_rows($result) - 1; $i >= 0; $i--) { if (!mysql_data_seek($result, $i)) { echo "Cannot seek to row $i\n"; continue; @@ -623,17 +621,17 @@ latin1 ]]> @@ -753,12 +751,12 @@ while ($i < $cnt) { "; -mysql_select_db("nonexistentdb"); -echo mysql_errno().": ".mysql_error()."
"; -$conn = mysql_query("SELECT * FROM nonexistenttable"); -echo mysql_errno().": ".mysql_error()."
"; + mysql_connect("kossu"); + echo mysql_errno().": ".mysql_error()."
"; + mysql_select_db("nonexistentdb"); + echo mysql_errno().": ".mysql_error()."
"; + $conn = mysql_query("SELECT * FROM nonexistenttable"); + echo mysql_errno().": ".mysql_error()."
"; ?> ]]>
@@ -802,12 +800,12 @@ echo mysql_errno().": ".mysql_error()."
"; "; -mysql_select_db("nonexistentdb"); -echo mysql_errno().": ".mysql_error()."
"; -$conn = mysql_query("SELECT * FROM nonexistenttable"); -echo mysql_errno().": ".mysql_error()."
"; + mysql_connect("marliesle"); + echo mysql_errno().": ".mysql_error()."
"; + mysql_select_db("nonexistentdb"); + echo mysql_errno().": ".mysql_error()."
"; + $conn = mysql_query("SELECT * FROM nonexistenttable"); + echo mysql_errno().": ".mysql_error()."
"; ?> ]]>
@@ -852,21 +850,21 @@ echo mysql_errno().": ".mysql_error()."
"; <function>mysql_real_escape_string</function> example - + +]]> The above example would produce the following output: - + @@ -948,16 +946,16 @@ select tone.field as foo ttwo.field as bar from tone, ttwo \n"; - echo "user_id: ".$row[0]."
\n"; - echo "fullname: ".$row["fullname"]."
\n"; - echo "fullname: ".$row[1]."
\n"; -} -mysql_free_result($result); + mysql_connect($host, $user, $password); + mysql_select_db("database"); + $result = mysql_query("select user_id, fullname from table"); + while ($row = mysql_fetch_array($result)) { + echo "user_id: ".$row["user_id"]."
\n"; + echo "user_id: ".$row[0]."
\n"; + echo "fullname: ".$row["fullname"]."
\n"; + echo "fullname: ".$row[1]."
\n"; + } + mysql_free_result($result); ?> ]]>
@@ -1015,15 +1013,15 @@ mysql_free_result($result); ]]> @@ -1131,7 +1129,7 @@ mysql_connect('localhost:3306', $user, $password) mysql_select_db("database"); $result = mysql_query("select * from table") or die("Query failed"); -# get column metadata +/* get column metadata */ $i = 0; while ($i < mysql_num_fields($result)) { echo "Information for column $i:
\n"; @@ -1139,7 +1137,7 @@ while ($i < mysql_num_fields($result)) { if (!$meta) { echo "No information available
\n"; } - echo "
+    echo "
 blob:         $meta->blob
 max_length:   $meta->max_length
 multiple_key: $meta->multiple_key
@@ -1152,7 +1150,7 @@ type:         $meta->type
 unique_key:   $meta->unique_key
 unsigned:     $meta->unsigned
 zerofill:     $meta->zerofill
-
"; +
"; $i++; } mysql_free_result($result); @@ -1225,9 +1223,9 @@ mysql_free_result($result); field; -// this is invalid +/* this is invalid */ echo $row->0; ?> @@ -1366,10 +1364,11 @@ mysql_free_result($result); <function>mysql_field_name</function> example "; -echo "The table has the following fields
"; +echo "Your '".$table."' table has ".$fields." fields and ".$rows." records
"; +echo "The table has the following fields
"; while ($i < $fields) { $type = mysql_field_type($result, $i); $name = mysql_field_name($result, $i); $len = mysql_field_len($result, $i); $flags = mysql_field_flags($result, $i); - echo $type." ".$name." ".$len." ".$flags."
"; + echo $type." ".$name." ".$len." ".$flags."
"; $i++; } mysql_close(); @@ -1716,7 +1714,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"; } ]]>
@@ -1775,7 +1773,7 @@ while ($row = mysql_fetch_row($result)){ $row["Command"], $row["Time"]); } mysql_free_result ($result); - +?> ]]> @@ -2078,7 +2076,7 @@ $result = mysql_query("SELECT * WHERE 1=1") ]]> @@ -2199,17 +2197,17 @@ $result = mysql_query("SELECT my_col FROM my_tbl") ]]> The above example would produce the following output: @@ -2332,10 +2330,10 @@ Escaped string: Zak\'s Laptop "; + echo $tb_names[$i] . "
"; } ?> ]]> @@ -2367,8 +2365,9 @@ for ($i = 0; $i < mysql_num_rows($result); $i++) { $link = mysql_connect('localhost', 'myname', 'secret'); $thread_id = mysql_thread_id($link); if ($thread_id){ - printf ("current thread id is %d\n", $thread_id); + printf ("current thread id is %d\n", $thread_id); } +?> ]]> @@ -2508,8 +2507,10 @@ current thread_id is 73 <function>mysql_stat</function> example ]]> diff --git a/functions/uodbc.xml b/functions/uodbc.xml index 97ac97c646..d8b4465d32 100644 --- a/functions/uodbc.xml +++ b/functions/uodbc.xml @@ -1,35 +1,19 @@ - + Unified ODBC functions ODBC - + In addition to normal ODBC support, the Unified ODBC functions in PHP allow you to access several databases that have borrowed the semantics of the ODBC API to implement their own API. Instead of maintaining multiple database drivers that were all nearly identical, these drivers have been unified into a single set of ODBC functions. - - - The following databases are supported by the Unified ODBC - functions: Adabas D, IBM DB2, iODBC, Solid, and Sybase SQL Anywhere. - - + - + There is no ODBC involved when connecting to the above databases. The functions that you use to speak natively to them just happen to share the same names and syntax as the ODBC @@ -38,8 +22,49 @@ applications. iODBC is maintained by OpenLink Software. More information on iODBC, as well as a HOWTO, is available at www.iodbc.org. - + + +
+ + The following databases are supported by the Unified ODBC + functions: Adabas D, IBM DB2, iODBC, Solid, and Sybase SQL Anywhere. + +
+ +
+ + Please see the Installation on Unix + Systems chapter for more information about configuring PHP + with these databases. + +
+ +
+ Runtime Configuration + + This extension does not define any configuration directives. + +
+ +
+ Resource types + + This extension does not define any resource types. + +
+ +
+ Predefined constants + + This extension does not define any constants. + +
@@ -50,9 +75,9 @@ Description - intodbc_autocommit - intconnection_id - intOnOff + boolodbc_autocommit + resourceconnection_id + boolOnOff Without the OnOff parameter, this function @@ -87,7 +112,7 @@ Description intodbc_binmode - intresult_id + resourceresult_id intmode @@ -195,7 +220,7 @@ Description voidodbc_close - intconnection_id + resourceconnection_id odbc_close will close down the connection to @@ -243,8 +268,8 @@ Description - intodbc_commit - intconnection_id + boolodbc_commit + resourceconnection_id Returns: &true; on success, @@ -262,7 +287,7 @@ Description - intodbc_connect + resourceodbc_connect stringdsn stringuser stringpassword @@ -330,7 +355,7 @@ Description stringodbc_cursor - intresult_id + resourceresult_id odbc_cursor will return a cursorname for the given result_id. @@ -346,8 +371,8 @@ Description - intodbc_do - intconn_id + resourceodbc_do + resourceconn_id stringquery @@ -366,7 +391,7 @@ Description stringodbc_error - intconnection_id + resourceconnection_id Returns a six-digit ODBC state, or an empty string if there @@ -390,7 +415,7 @@ Description stringodbc_errormsg - intconnection_id + resourceconnection_id Returns a string containing the last ODBC error message, or an empty @@ -414,8 +439,8 @@ Description - intodbc_exec - intconnection_id + resourceodbc_exec + resourceconnection_id stringquery_string @@ -445,8 +470,8 @@ Description - intodbc_execute - intresult_id + resourceodbc_execute + resourceresult_id arrayparameters_array @@ -509,12 +534,18 @@ Description - - intodbc_fetch_into - intresult_id - intrownumber - arrayresult_array - + + boolodbc_fetch_into + resourceresult_id + intrownumber + arrayresult_array + + + resourceodbc_fetch_into + resourceresult_id + arrayresult_array + intrownumber + Returns the number of columns in the result; &false; on error. @@ -523,14 +554,28 @@ array. The array will contain the column values starting at array index 0. - - - <function>odbc_fetch_into</function> pre 4.0.6 example - + + As of PHP 4.0.5 the result_array does not + need to be passed by reference any longer. + + + As of PHP 4.0.6 the rownumber cannot be + passed as a constant, but rather as a variable. + + + As of PHP 4.2.0 the result_array and + rownumber have been swapped. This allows the + rownumber to be a constant again. This change will also be the last one + to this function. + + + + <function>odbc_fetch_into</function> pre 4.0.6 example + - + or @@ -540,50 +585,48 @@ $rc = odbc_fetch_into($res_id, $row, $my_array); $rc = odbc_fetch_into($res_id, 1, $my_array); ]]> - - - - - As of PHP 4.0.5 the result_array does not - need to be passed by reference any longer. - - - As of PHP 4.0.6 the rownumber cannot be - passed as a constant, but rather as a variable. - - - - <function>odbc_fetch_into</function> 4.0.6 example - + + + + + + <function>odbc_fetch_into</function> 4.0.6 example + - - - or - - + + + or + + - - - - - Future: In PHP 4.1, this function will be moved to the following - format: - - intodbc_fetch_into - intresult_id - arrayresult_array - intrownumber - - Please note, that rownumber will be optional, - while result_array is not. - - - + + +
+ + + <function>odbc_fetch_into</function> 4.2.0 example + + + + + or + + + + + + + + @@ -593,8 +636,8 @@ $rc = odbc_fetch_into($res_id, $row, $my_array); Description - intodbc_fetch_row - intresult_id + boolodbc_fetch_row + resourceresult_id introw_number @@ -639,7 +682,7 @@ $rc = odbc_fetch_into($res_id, $row, $my_array); Description arrayodbc_fetch_array - intresult + resourceresult intrownumber @@ -659,7 +702,7 @@ $rc = odbc_fetch_into($res_id, $row, $my_array); Description boolodbc_next_result - intresult_id + resourceresult_id &warn.undocumented.func; @@ -678,7 +721,7 @@ $rc = odbc_fetch_into($res_id, $row, $my_array); Description objectodbc_fetch_object - intresult + resourceresult intrownumber @@ -696,7 +739,7 @@ $rc = odbc_fetch_into($res_id, $row, $my_array); Description stringodbc_field_name - intresult_id + resourceresult_id intfield_number @@ -717,7 +760,7 @@ $rc = odbc_fetch_into($res_id, $row, $my_array); Description intodbc_field_num - intresult_id + resourceresult_id stringfield_name @@ -738,7 +781,7 @@ $rc = odbc_fetch_into($res_id, $row, $my_array); Description stringodbc_field_type - intresult_id + resourceresult_id intfield_number @@ -758,7 +801,7 @@ $rc = odbc_fetch_into($res_id, $row, $my_array); Description intodbc_field_len - intresult_id + resourceresult_id intfield_number @@ -782,7 +825,7 @@ $rc = odbc_fetch_into($res_id, $row, $my_array); Description stringodbc_field_precision - intresult_id + resourceresult_id intfield_number @@ -806,7 +849,7 @@ $rc = odbc_fetch_into($res_id, $row, $my_array); Description stringodbc_field_scale - intresult_id + resourceresult_id intfield_number @@ -825,8 +868,8 @@ $rc = odbc_fetch_into($res_id, $row, $my_array); Description - intodbc_free_result - intresult_id + boolodbc_free_result + resourceresult_id Always returns &true;. @@ -860,11 +903,11 @@ $rc = odbc_fetch_into($res_id, $row, $my_array); Description - + intodbc_longreadlen - intresult_id - intlength - + resourceresult_id + intlength + (ODBC SQL types affected: LONG, LONGVARBINARY) The number of bytes returned to PHP is controled by the parameter length. If it @@ -887,10 +930,10 @@ $rc = odbc_fetch_into($res_id, $row, $my_array); Description - - intodbc_num_fields - intresult_id - + + intodbc_num_fields + resourceresult_id + odbc_num_fields will return the number of fields (columns) in an ODBC result. This function will return -1 @@ -949,8 +992,8 @@ $rc = odbc_fetch_into($res_id, $row, $my_array); Description - intodbc_prepare - intconnection_id + resourceodbc_prepare + resourceconnection_id stringquery_string @@ -973,7 +1016,7 @@ $rc = odbc_fetch_into($res_id, $row, $my_array); Description intodbc_num_rows - intresult_id + resourceresult_id odbc_num_rows will return the number of rows @@ -1000,7 +1043,7 @@ $rc = odbc_fetch_into($res_id, $row, $my_array); Description stringodbc_result - intresult_id + resourceresult_id mixedfield @@ -1060,7 +1103,7 @@ longer than 4096 bytes, the contents is not Description intodbc_result_all - intresult_id + resourceresult_id stringformat @@ -1086,7 +1129,7 @@ longer than 4096 bytes, the contents is not Description intodbc_rollback - intconnection_id + resourceconnection_id Rolls back all pending statements on @@ -1109,7 +1152,7 @@ longer than 4096 bytes, the contents is not Description intodbc_setoption - intid + resourceid intfunction intoption intparam @@ -1135,7 +1178,7 @@ longer than 4096 bytes, the contents is not matters. - ID is a connection id or result id on + id is a connection id or result id on which to change the settings.For SQLSetConnectOption(), this is a connection id. For SQLSetStmtOption(), this is a result id. @@ -1187,7 +1230,7 @@ odbc_execute ($result); Description intodbc_tables - intconnection_id + resourceconnection_id stringqualifier stringowner stringname @@ -1282,7 +1325,7 @@ odbc_execute ($result); Description intodbc_tableprivileges - intconnection_id + resourceconnection_id stringqualifier stringowner stringname @@ -1328,7 +1371,7 @@ odbc_execute ($result); Description intodbc_columns - intconnection_id + resourceconnection_id stringqualifier stringowner stringtable_name @@ -1385,7 +1428,7 @@ odbc_execute ($result); Description intodbc_columnprivileges - intconnection_id + resourceconnection_id stringqualifier stringowner stringtable_name @@ -1432,7 +1475,7 @@ odbc_execute ($result); Description intodbc_gettypeinfo - intconnection_id + resourceconnection_id intdata_type @@ -1478,8 +1521,8 @@ odbc_execute ($result); Description - intodbc_primarykeys - intconnection_id + resourceodbc_primarykeys + resourceconnection_id stringqualifier stringowner stringtable @@ -1515,8 +1558,8 @@ odbc_execute ($result); Description - intodbc_foreignkeys - intconnection_id + resourceodbc_foreignkeys + resourceconnection_id stringpk_qualifier stringpk_owner stringpk_table @@ -1581,8 +1624,8 @@ odbc_execute ($result); Description - intodbc_procedures - intconnection_id + resourceodbc_procedures + resourceconnection_id stringqualifier stringowner stringname @@ -1622,8 +1665,8 @@ odbc_execute ($result); Description - intodbc_procedurecolumns - intconnection_id + resourceodbc_procedurecolumns + resourceconnection_id stringqualifier stringowner stringproc @@ -1676,8 +1719,8 @@ odbc_execute ($result); Description - intodbc_specialcolumns - intconnection_id + resourceodbc_specialcolumns + resourceconnection_id inttype stringqualifier stringowner @@ -1728,8 +1771,8 @@ odbc_execute ($result); Description - intodbc_statistics - intconnection_id + resourceodbc_statistics + resourceconnection_id stringqualifier stringowner stringtable_name