corrected errors, corrected grammer issues, clarified some examples, added missing examples, added some of the examples from errata notes, clarifed information mentioned in errata notes, a few small formatting changes

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@32214 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Daniel Beckham 2000-09-07 18:56:23 +00:00
parent 33c0beba6c
commit ebdd57d3fa

View file

@ -123,21 +123,22 @@
<para>
Returns: true on success, false on error.
</para>
<para>
<function>mysql_close</function> closes the link to a MySQL
database that's associated with the specified link identifier.
If the link identifier isn't specified, the last opened link is
assumed.
<para> <function>mysql_close</function> closes the connection to
the MySQL server that's associated with the specified link
identifier. If <parameter>link_identifier</parameter> isn't
specified, the last opened link is used.
</para>
<note><para>
This isn't usually necessary, as non-persistent open
links are automatically closed at the end of the script's
execution.
</para></note>
<para>
<function>mysql_close</function> will not close persistent links
generated by <function>mysql_pconnect</function>.
<para>
Using <function>mysql_close</function> isn't usually necessary,
as non-persistent open links are automatically closed at the end
of the script's execution.
</para>
<note>
<para>
<function>mysql_close</function> will not close persistent links
created by <function>mysql_pconnect</function>.
</para>
</note>
<example>
<title>MySQL close example</title>
<programlisting role="php">
@ -187,15 +188,17 @@
</funcprototype>
</funcsynopsis>
<para>
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.
</para>
<para>
<function>mysql_connect</function> establishes a connection to a
MySQL server. All of the arguments are optional, and if they're
missing, defaults are assumed ('localhost', user name of the user
that owns the server process, empty password).
</para>
<para>
<function>mysql_connect</function> establishes a connection
to a MySQL server. The following defaults are assumed for
missing optional parameters: <parameter>host:port</parameter> =
'localhost:3306', <parameter>username</parameter> = name of the
user that owns the server process and
<parameter>password</parameter> = empty password.
</para>
<para>
The hostname string can also include a port
number. eg. &quot;hostname:port&quot; or a path to a socket
@ -215,10 +218,10 @@
</note>
</para>
<para>
In case a second call is made to
<function>mysql_connect</function> with the same arguments, no
new link will be established, but instead, the link identifier of
the already opened link will be returned.
If a second call is made to <function>mysql_connect</function>
with the same arguments, no new link will be established, but
instead, the link identifier of the already opened link will be
returned.
</para>
<para>
The link to the server will be closed as soon as the execution of
@ -781,7 +784,7 @@ mysql_free_result ($result);
<paramdef>int <parameter>result</parameter></paramdef>
<paramdef>int
<parameter>
<optional>result_typ</optional>
<optional>result_type</optional>
</parameter>
</paramdef>
</funcprototype>
@ -798,7 +801,7 @@ mysql_free_result ($result);
their offsets (numbers are illegal property names).
</para>
<para>
The optional argument <parameter>result_typ</parameter> is a
The optional argument <parameter>result_type</parameter> is a
constant and can take the following values: MYSQL_ASSOC,
MYSQL_NUM, and MYSQL_BOTH.
</para>
@ -808,7 +811,7 @@ mysql_free_result ($result);
<function>mysql_fetch_row</function> (the difference is
insignificant).
<example>
<title>mysql fetch object</title>
<title><function>mysql_fetch_object</function> example</title>
<programlisting role="php">
&lt;?php
mysql_connect ($host, $user, $password);
@ -919,13 +922,43 @@ mysql_free_result ($result);
</funcsynopsis>
<para>
<function>mysql_field_name</function> returns the name of the
specified field. Arguments to the function is the result
identifier and the field index, ie.
<literal>mysql_field_name($result,2);</literal>
specified field index. <parameter>result</parameter> must be a
valid result identifier and <parameter>field_index</parameter> is
the numerical offset of the field.
</para>
<note>
<para>
<parameter>field_index</parameter> starts at 0.
</para>
<para>
e.g. The index of the third field would actually be 2, the index
of the fourth field would be 3 and so on.
</para>
</note>
<para>
<example>
<title><function>mysql_field_name</function> example</title>
<programlisting role="php">
// The users table consists of three fields:
// user_id
// username
// password.
$res = mysql_db_query("users", "select * from users", $link);
echo mysql_field_name($res, 0) . "\n";
echo mysql_field_name($res, 2);
</programlisting>
</example>
</para>
<para>
Will return the name of the second field in the result associated
with the result identifier.
The above example would produce the following output:
<informalexample>
<programlisting>
user_id
password
</programlisting>
</informalexample>
</para>
<para>
For downwards compatibility <function>mysql_fieldname</function>
@ -952,8 +985,11 @@ mysql_free_result ($result);
</funcsynopsis>
<para>
<function>mysql_field_len</function> returns the length of the
specified field. For downward compatibility
<function>mysql_fieldlen</function> can also be used.
specified field.
</para>
<para>
For downward compatibility <function>mysql_fieldlen</function>
can also be used.
</para>
</refsect1>
</refentry>
@ -976,8 +1012,9 @@ mysql_free_result ($result);
</funcsynopsis>
<para>
Seeks to the specified field offset. If the next call to
<function>mysql_fetch_field</function> won't include a field
offset, this field would be returned.
<function>mysql_fetch_field</function> doesn't include a field
offset, the field offset specified in
<function>mysql_field_seek</function> will be returned.
</para>
<para>
See also: <function>mysql_fetch_field</function>.
@ -1002,8 +1039,12 @@ mysql_free_result ($result);
</funcprototype>
</funcsynopsis>
<para>
Get the table name for field. For downward compatibility
<function>mysql_fieldtable</function> can also be used.
Returns the name of the table that the specifed field is
in.
</para>
<para>
For downward compatibility <function>mysql_fieldtable</function>
can also be used.
</para>
</refsect1>
</refentry>
@ -1027,13 +1068,15 @@ mysql_free_result ($result);
<para>
<function>mysql_field_type</function> is similar to the
<function>mysql_field_name</function> function. The arguments are
identical, but the field type is returned. This will be one of
"int", "real", "string", "blob", or others as detailed in the
MySQL documentation.
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 <ulink url="&url.mysql.docs;">MySQL
documentation</ulink>.
<example>
<title>mysql field types</title>
<programlisting role="php">
&lt;?php
mysql_connect ("localhost:3306");
mysql_select_db ("wisconsin");
$result = mysql_query ("SELECT * FROM onek");
@ -1052,6 +1095,7 @@ while ($i &lt; $fields) {
$i++;
}
mysql_close();
?>
</programlisting>
</example>
@ -1076,11 +1120,15 @@ mysql_close();
<paramdef>int <parameter>result</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>mysql_free_result</function> will free all memory
associated with the result identifier <parameter>result</parameter>.
</para>
<para>
<function>mysql_free_result</function> only needs to be called if
you are worried about using too much memory while your script is
running. All associated result memory for the specified result
identifier will automatically be freed.
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.
</para>
<para>
For downward compatibility <function>mysql_freeresult</function>
@ -1110,7 +1158,7 @@ mysql_close();
</funcsynopsis>
<para>
<function>mysql_insert_id</function> returns the ID generated for
an AUTO_INCREMENTED field. It will return the auto-generated ID
an AUTO_INCREMENT field. It will return the auto-generated ID
returned by the last INSERT query performed using the given
<parameter>link_identifier</parameter>. If
<parameter>link_identifier</parameter> isn't specified, the last
@ -1144,6 +1192,36 @@ mysql_close();
daemon. Use the <function>mysql_tablename</function> function to
traverse this result pointer.
</para>
<para>
<example>
<title><function>mysql_list_dbs</function> example</title>
<programlisting role="php">
$link = mysql_connect('localhost', 'myname', 'secret');
$db_list = mysql_list_dbs($link);
while ($row = mysql_fetch_object($db_list)) {
echo $row->Database . "\n";
}
</programlisting>
</example>
</para>
<para>
The above example would produce the following output:
<informalexample>
<programlisting>
database1
database2
database3
...
</programlisting>
</informalexample>
</para>
<note>
<para>
The above code would just as easily work with
<function>mysql_fetch_row</function> or other similar functions.
</para>
</note>
<para>
For downward compatibility <function>mysql_listdbs</function> can
also be used.
@ -1186,6 +1264,32 @@ mysql_close();
was called as <literal>@mysql()</literal> then this error string
will also be printed out.
</para>
<para>
<example>
<title><function>mysql_list_fields</function> example</title>
<programlisting role="php">
$link = mysql_connect('localhost', 'myname', 'secret');
$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";;
}
</programlisting>
</example>
</para>
<para>
The above example would produce the following output:
<informalexample>
<programlisting>
field1
field2
field3
...
</programlisting>
</informalexample>
</para>
<para>
For downward compatibility <function>mysql_listfields</function>
can also be used.
@ -1320,11 +1424,13 @@ mysql_close();
or false on error.
</para>
<para>
<function>mysql_pconnect</function> establishes a connection to a
MySQL server. All of the arguments are optional, and if they're
missing, defaults are assumed ('localhost', user name of the user
that owns the server process, empty password).
</para>
<function>mysql_pconnect</function> establishes a connection
to a MySQL server. The following defaults are assumed for
missing optional parameters: <parameter>host:port</parameter> =
'localhost:3306', <parameter>username</parameter> = name of the
user that owns the server process and
<parameter>password</parameter> = empty password.
</para>
<para>
The hostname string can also include a port
number. eg. &quot;hostname:port&quot; or a path to a socket
@ -1386,9 +1492,11 @@ mysql_close();
to establish a link as if <function>mysql_connect</function> was
called with no arguments, and use it.
</para>
<para>
The query string should not end with a semicolon.
</para>
<note>
<para>
The query string should not end with a semicolon.
</para>
</note>
<para>
<function>mysql_query</function> returns TRUE (non-zero) or FALSE
to indicate whether or not the query succeeded. A return value
@ -1432,14 +1540,20 @@ $result = mysql_query ("SELECT my_col FROM my_tbl")
</para>
<para>
Assuming the query succeeds, you can call
<function>mysql_num_rows</function> to find out how many rows
were returned for a SELECT statment or
<function>mysql_affected_rows</function> to find out how many
rows were affected (for DELETE, INSERT, REPLACE, or UPDATE
statements). For SELECT statements,
<function>mysql_query</function> returns a new result identifier
that you can pass to <function>mysql_result</function>. When you
are done with the result set, you can free the resources
associated with it by calling
<function>mysql_free_result</function>.
rows were affected by a DELETE, INSERT, REPLACE, or UPDATE
statement.
</para>
<para>
For SELECT statements, <function>mysql_query</function> returns a
new result identifier that you can pass to
<function>mysql_result</function>. When you are done with the
result set, you can free the resources associated with it by
calling <function>mysql_free_result</function>. Although, the
memory will automatically be freed at the end of the script's
execution.
</para>
<para>
See also: <function>mysql_affected_rows</function>,