documented mysqli_connect_errno/error functions

more samples added


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@151906 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Georg Richter 2004-02-20 08:54:11 +00:00
parent 33fccbb39e
commit 1dd6357dd0
6 changed files with 264 additions and 30 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<refentry id="function.mysqli-character-set-name">
<refnamediv>
<refname>mysqli_character_set_name</refname>
@ -31,32 +31,51 @@
<title>Return values</title>
<para>The default character set for the current connection</para>
</refsect1>
<refsect1>
<title>See also</title>
<para>
<function>mysqli_client_encoding</function>.
<function>mysqli_real_escape_string</function>.
</para>
</refsect1>
<refsect1>
<title>Example</title>
<example>
<title>Using the mysqli_character_set_name function</title>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
/* Open a connection */
$link = mysqli_connect("localhost", "username", "password");
$mysqli = new mysqli("localhost", "my_user", "my_password");
/* Print current character set */
$charset = $mysqli->character_set_name();
printf ("Current character set is %s\n", $charset);
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
/* Open a connection */
$link = mysqli_connect("localhost", "my_user", "my_password");
/* Print current character set */
$charset = mysqli_character_set_name($link);
printf ("Current character set is %s\n",$charset);
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
</refsect1>
<refsect1>
<title>See also</title>
<para>
<function>mysqli_real_escape_string</function>.
</para>
</refsect1>
</programlisting>
</example>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<!-- $Revision: 1.2 $ -->
<refentry id="function.mysqli-client-encoding">
<refnamediv>
<refname>mysqli_client_encoding</refname>
@ -9,6 +9,15 @@
<title>Description</title>
<para>
This function is an alias of <function>mysqli_character_set_name</function>.
For a detailled descripton see description of
<function>mysqli_character_set_name</function>.
</para>
</refsect1>
<refsect1>
<title>See also</title>
<para>
<function>mysqli_client_encoding</function>.
<function>mysqli_real_escape_string</function>.
</para>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- $Revision: 1.5 $ -->
<refentry id="function.mysqli-commit">
<refnamediv>
<refname>mysqli_commit</refname>
@ -40,6 +40,65 @@
<function>mysqli_rollback</function>.
</para>
</refsect1>
<refsect1>
<title>Examples</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$mysqli->query("DROP TABLE IF EXISTS ta_sample");
$mysqli->query("CREATE TABLE ta_sample (a int) TYPE=InnoDB");
/* set autocommit to off */
$mysqli->autocommit(FALSE);
/* Insert some values */
$mysqli->query("INSERT INTO ta_sample VALUES (1)");
$mysqli->query("INSERT INTO ta_sample VALUES (1)");
/* commit transaction */
$mysqli->commit();
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
mysqli_query($link, "DROP TABLE IF EXISTS ta_sample");
mysqli_query($link, "CREATE TABLE ta_sample (a int) TYPE=InnoDB");
/* set autocommit to off */
mysqli_autocommit($link, FALSE);
/* Insert some values */
mysqli_query($link, "INSERT INTO ta_sample VALUES (1)");
mysqli_query($link, "INSERT INTO ta_sample VALUES (1)");
/* commit transaction */
mysqli_commit($link);
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View file

@ -1,19 +1,66 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<!-- $Revision: 1.2 $ -->
<refentry id="function.mysqli-connect-errno">
<refnamediv>
<refname>mysqli_connect_errno</refname>
<refpurpose>Returns the numerical value of the error message from last connect command.</refpurpose>
<refpurpose>Returns the error code from last connect call</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>mysqli_connect_errno</methodname>
<void/>
</methodsynopsis>
<methodsynopsis>
<type>int</type><methodname>mysqli_connect_errno</methodname>
<methodparam><type>void</type><parameter></parameter></methodparam>
</methodsynopsis>
<para>
The <function>mysqli_connect_errno</function> function will return the last error code number
for last call to <function>mysqli_connect</function>.
If no errors have occured, this function will return zero.
</para>
<note>
<para>
Client error message numbers are listed in the MySQL <filename>errmsg.h</filename> header file,
server error message numbers are listed in <filename>mysqld_error.h</filename>.
In the MySQL source distribution you can find a complete list of error messages and error numbers
in the file <filename>Docs/mysqld_error.txt</filename>.
</para>
</note>
</refsect1>
<refsect1>
<title>Return values</title>
<para>
An error code value for the last call to <function>mysqli_connect</function>, if it failed.
zero means no error occurred.
</para>
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>mysqli_connect_errno sample</title>
<programlisting role="php">
<![CDATA[
<?php
&warn.undocumented.func;
$link = @mysqli_connect("localhost", "nonexisting_user", "");
if (!$link) {
printf("Can't connect to localhost. Errorcode: %d\n", mysqli_connect_errno());
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1>
<title>See also</title>
<para>
<function>mysqli_connect</function>,
<function>mysqli_connect_error</function>,
<function>mysqli_errno</function>,
<function>mysqli_error</function>,
<function>mysqli_sqlstate</function>
</para>
</refsect1>
</refentry>

View file

@ -1,19 +1,60 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<!-- $Revision: 1.2 $ -->
<refentry id="function.mysqli-connect-error">
<refnamediv>
<refname>mysqli_connect_error</refname>
<refpurpose>Returns the text of the error message from previous MySQL operation.</refpurpose>
<refpurpose>Returns a string description of the last connect error</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mysqli_connect_error</methodname>
<void/>
</methodsynopsis>
<methodsynopsis>
<type>string</type><methodname>mysqli_connect_error</methodname>
<methodparam><type>void</type><parameter></parameter></methodparam>
</methodsynopsis>
<para>
The <function>mysqli_connect_error</function> function is identical to the corresponding
<function>mysqli_connect_errno</function> function in every way, except instead of returning
an integer error code the <function>mysqli_connect_error</function> function will return
a string representation of the last error to occur for the last
<function>mysqli_connect</function> call.
If no error has occured, this function will return an empty string.
</para>
</refsect1>
<refsect1>
<title>Return values</title>
<para>
A string that describes the error. An empty string if no error occurred.
</para>
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>mysqli_connect_error sample</title>
<programlisting role="php">
<![CDATA[
<?php
&warn.undocumented.func;
$link = @mysqli_connect("localhost", "nonexisting_user", "");
if (!$link) {
printf("Can't connect to localhost. Error: %s\n", mysqli_connect_error());
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1>
<title>See also</title>
<para>
<function>mysqli_connect</function>,
<function>mysqli_connect_errno</function>,
<function>mysqli_errno</function>,
<function>mysqli_error</function>,
<function>mysqli_sqlstate</function>
</para>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<refentry id="function.mysqli-rollback">
<refnamediv>
<refname>mysqli_rollback</refname>
@ -38,6 +38,65 @@
<function>mysqli_autocommit</function>
</para>
</refsect1>
<refsect1>
<title>Examples</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$mysqli->query("DROP TABLE IF EXISTS ta_sample");
$mysqli->query("CREATE TABLE ta_sample (a int) TYPE=InnoDB");
/* set autocommit to off */
$mysqli->autocommit(FALSE);
/* Insert some values */
$mysqli->query("INSERT INTO ta_sample VALUES (1)");
$mysqli->query("INSERT INTO ta_sample VALUES (1)");
/* rollback transaction */
$mysqli->rollback();
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
mysqli_query($link, "DROP TABLE IF EXISTS ta_sample");
mysqli_query($link, "CREATE TABLE ta_sample (a int) TYPE=InnoDB");
/* set autocommit to off */
mysqli_autocommit($link, FALSE);
/* Insert some values */
mysqli_query($link, "INSERT INTO ta_sample VALUES (1)");
mysqli_query($link, "INSERT INTO ta_sample VALUES (1)");
/* rollback transaction */
mysqli_rollback($link);
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file