georg Thu Feb 26 09:48:54 2004 EDT
Modified files:
/phpdoc/en/reference/mysqli/functions mysqli-more-results.xml
mysqli-multi-query.xml
mysqli-next-result.xml
mysqli-num-fields.xml
mysqli-num-rows.xml
mysqli-options.xml
mysqli-param-count.xml
mysqli-ping.xml
mysqli-prepare.xml
mysqli-query.xml
mysqli-real-connect.xml
Log:
added more samples
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-more-results.xml?r1=1.1&r2=1.2&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-more-results.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-more-results.xml:1.1
phpdoc/en/reference/mysqli/functions/mysqli-more-results.xml:1.2
--- phpdoc/en/reference/mysqli/functions/mysqli-more-results.xml:1.1 Sun Feb 8
08:14:42 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-more-results.xml Thu Feb 26
09:48:54 2004
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
<refentry id="function.mysqli-more-results">
<refnamediv>
<refname>mysqli_more_results</refname>
+ <refname>mysqli->more_results</refname>
<refpurpose>Check if there any more query results from a multi query.</refpurpose>
</refnamediv>
<refsect1>
@@ -11,9 +12,27 @@
<type>bool</type><methodname>mysqli_more_results</methodname>
<methodparam><type>object</type><parameter>link</parameter></methodparam>
</methodsynopsis>
-
- &warn.undocumented.func;
-
+ <para>
+ <function>mysqli_more_results</function> indicates if one or more result sets
+ are available from a previous call to <function>mysqli_multi_query</function>.
+ </para>
+ </refsect1>
+ <refsect1>
+ <title>Return values</title>
+ <para>&return.success;</para>
+ </refsect1>
+ <refsect1>
+ <title>See also</title>
+ <para>
+ <function>mysqli_multi_query</function>,
+ <function>mysqli_next_result</function>,
+ <function>mysqli_store_result</function>,
+ <function>mysqli_use_result</function>
+ </para>
+ </refsect1>
+ <refsect1>
+ <title>Example</title>
+ <para>See <function>mysqli_multi_query</function>.</para>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-multi-query.xml?r1=1.1&r2=1.2&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-multi-query.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-multi-query.xml:1.1
phpdoc/en/reference/mysqli/functions/mysqli-multi-query.xml:1.2
--- phpdoc/en/reference/mysqli/functions/mysqli-multi-query.xml:1.1 Fri Jan 30
17:51:43 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-multi-query.xml Thu Feb 26 09:48:54
2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
<refentry id="function.mysqli-multi-query">
<refnamediv>
<refname>mysqli_multi_query</refname>
@@ -49,6 +49,101 @@
<function>mysqli_more_results</function>
</para>
</refsect1>
+ <refsect1>
+ <title>Example</title>
+ <example>
+ <title>Object oriented style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+$query = "SELECT CURRENT_USER();";
+$query .= "SELECT Name FROM City ORDER BY ID LIMIT 20, 5";
+
+/* execute multi query */
+if ($mysqli->multi_query($query)) {
+ do {
+ /* store first result set */
+ if ($result = $mysqli->store_result()) {
+ while ($row = $result->fetch_row()) {
+ printf("%s\n", $row[0]);
+ }
+ $result->close();
+ }
+ /* print divider */
+ if ($mysqli->more_results()) {
+ printf("-----------------\n");
+ }
+ } while ($mysqli->next_result());
+}
+
+/* close connection */
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+ </example>
+ <example>
+ <title>Procedural style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$link = mysqli_connect("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+$query = "SELECT CURRENT_USER();";
+$query .= "SELECT Name FROM City ORDER BY ID LIMIT 20, 5";
+
+/* execute multi query */
+if (mysqli_multi_query($link, $query)) {
+ do {
+ /* store first result set */
+ if ($result = mysqli_store_result($link)) {
+ while ($row = mysqli_fetch_row($result)) {
+ printf("%s\n", $row[0]);
+ }
+ mysqli_free_result($result);
+ }
+ /* print divider */
+ if (mysqli_more_results($link)) {
+ printf("-----------------\n");
+ }
+ } while (mysqli_next_result($link));
+}
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+ </example>
+ <para>
+ The above examples would produce the following output:
+ </para>
+ <screen>
+<![CDATA[
[EMAIL PROTECTED]
+-----------------
+Amersfoort
+Maastricht
+Dordrecht
+Leiden
+Haarlemmermeer
+]]>
+ </screen>
+ </refsect1>
</refentry>
<!-- Keep this comment at the end of the file
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-next-result.xml?r1=1.1&r2=1.2&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-next-result.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-next-result.xml:1.1
phpdoc/en/reference/mysqli/functions/mysqli-next-result.xml:1.2
--- phpdoc/en/reference/mysqli/functions/mysqli-next-result.xml:1.1 Sun Feb 8
08:14:42 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-next-result.xml Thu Feb 26 09:48:54
2004
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
<refentry id="function.mysqli-next-result">
<refnamediv>
<refname>mysqli_next_result</refname>
- <refpurpose>Read next result from multi_query.</refpurpose>
+ <refname>mysqli->next_result</refname>
+ <refpurpose>prepare next result from multi_query.</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
@@ -11,9 +12,31 @@
<type>bool</type><methodname>mysqli_next_result</methodname>
<methodparam><type>object</type><parameter>link</parameter></methodparam>
</methodsynopsis>
-
- &warn.undocumented.func;
-
+ <para>
+ <function>mysqli_next_result</function> prepares next result set from a previous
+ call to <function>mysqli_multi_query</function> which can be retrieved by
+ <function>mysqli_store_result</function> or
+ <function>mysqli_use_result</function>.
+ </para>
+ </refsect1>
+ <refsect1>
+ <title>Return values</title>
+ <para>&return.success;</para>
+ </refsect1>
+ <refsect1>
+ <title>See also</title>
+ <para>
+ <function>mysqli_multi_query</function>,
+ <function>mysqli_more_results</function>,
+ <function>mysqli_store_result</function>,
+ <function>mysqli_use_result</function>
+ </para>
+ </refsect1>
+ <refsect1>
+ <title>Example</title>
+ <para>
+ See <function>mysqli_multi_query</function>.
+ </para>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-num-fields.xml?r1=1.3&r2=1.4&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-num-fields.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-num-fields.xml:1.3
phpdoc/en/reference/mysqli/functions/mysqli-num-fields.xml:1.4
--- phpdoc/en/reference/mysqli/functions/mysqli-num-fields.xml:1.3 Wed Jan 28
18:18:42 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-num-fields.xml Thu Feb 26 09:48:54
2004
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<refentry id="function.mysqli-num-fields">
<refnamediv>
<refname>mysqli_num_fields</refname>
- <refname>result->num_fields</refname>
+ <refname>result->field_count</refname>
<refpurpose>
Get the number of fields in a result
</refpurpose>
@@ -17,7 +17,7 @@
</methodsynopsis>
<para>Object oriented style (property):</para>
<classsynopsis>
- <ooclass><classname>mysqli</classname></ooclass>
+ <ooclass><classname>result</classname></ooclass>
<fieldsynopsis><type>int</type><varname>field_count</varname></fieldsynopsis>
</classsynopsis>
<para>
@@ -34,6 +34,77 @@
<function>mysqli_fetch_field</function>
</para>
</refsect1>
+ <refsect1>
+ <title>Example</title>
+ <example>
+ <title>Object oriented style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+if ($result = $mysqli->query("SELECT * FROM City ORDER BY ID LIMIT 1")) {
+
+ /* determine number of fields in result set */
+ $field_cnt = $result->field_count;
+
+ printf("Result set has %d fields.\n", $field_cnt);
+
+ /* close result set */
+ $result->close();
+}
+
+/* close connection */
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+ </example>
+ <example>
+ <title>Procedural style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$link = mysqli_connect("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+if ($result = mysqli_query($link, "SELECT * FROM City ORDER BY ID LIMIT 1")) {
+
+ /* determine number of fields in result set */
+ $field_cnt = mysqli_num_fields($result);
+
+ printf("Result set has %d fields.\n", $field_cnt);
+
+ /* close result set */
+ mysqli_free_result($result);
+}
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+ </example>
+ <para>
+ The above examples would produce the following output:
+ </para>
+ <screen>
+<![CDATA[
+Result set has 5 fields.
+]]>
+ </screen>
+ </refsect1>
</refentry>
<!-- Keep this comment at the end of the file
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-num-rows.xml?r1=1.4&r2=1.5&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-num-rows.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-num-rows.xml:1.4
phpdoc/en/reference/mysqli/functions/mysqli-num-rows.xml:1.5
--- phpdoc/en/reference/mysqli/functions/mysqli-num-rows.xml:1.4 Wed Jan 28
18:18:42 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-num-rows.xml Thu Feb 26 09:48:54
2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
<refentry id="function.mysqli-num-rows">
<refnamediv>
<refname>mysqli_num_rows</refname>
@@ -51,6 +51,77 @@
<function>mysqli_query</function>
</para>
</refsect1>
+ <refsect1>
+ <title>Example</title>
+ <example>
+ <title>Object oriented style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+if ($result = $mysqli->query("SELECT Code, Name FROM Country ORDER BY Name")) {
+
+ /* determine number of rows result set */
+ $row_cnt = $result->num_rows;
+
+ printf("Result set has %d rows.\n", $row_cnt);
+
+ /* close result set */
+ $result->close();
+}
+
+/* close connection */
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+ </example>
+ <example>
+ <title>Procedural style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$link = mysqli_connect("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+if ($result = mysqli_query($link, "SELECT Code, Name FROM Country ORDER BY Name")) {
+
+ /* determine number of rows result set */
+ $row_cnt = mysqli_num_rows($result);
+
+ printf("Result set has %d rows.\n", $row_cnt);
+
+ /* close result set */
+ mysqli_free_result($result);
+}
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+ </example>
+ <para>
+ The above examples would produce the following output:
+ </para>
+ <screen>
+<![CDATA[
+Result set has 239 rows.
+]]>
+ </screen>
+ </refsect1>
</refentry>
<!-- Keep this comment at the end of the file
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-options.xml?r1=1.3&r2=1.4&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-options.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-options.xml:1.3
phpdoc/en/reference/mysqli/functions/mysqli-options.xml:1.4
--- phpdoc/en/reference/mysqli/functions/mysqli-options.xml:1.3 Wed Jan 28 18:18:42
2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-options.xml Thu Feb 26 09:48:54
2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<refentry id="function.mysqli-options">
<refnamediv>
<refname>mysqli_options</refname>
@@ -95,6 +95,10 @@
<function>mysqli_real_connect</function>
</para>
</refsect1>
+ <refsect1>
+ <title>Example</title>
+ <para>See <function>mysqli_real_connect</function>.</para>
+ </refsect1>
</refentry>
<!-- Keep this comment at the end of the file
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-param-count.xml?r1=1.5&r2=1.6&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-param-count.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-param-count.xml:1.5
phpdoc/en/reference/mysqli/functions/mysqli-param-count.xml:1.6
--- phpdoc/en/reference/mysqli/functions/mysqli-param-count.xml:1.5 Wed Jan 28
19:41:55 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-param-count.xml Thu Feb 26 09:48:54
2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.5 $ -->
+<!-- $Revision: 1.6 $ -->
<refentry id="function.mysqli-param-count">
<refnamediv>
<refname>mysqli_param_count</refname>
@@ -35,6 +35,73 @@
<function>mysqli_prepare</function>
</para>
</refsect1>
+ <refsect1>
+ <title>Example</title>
+ <example>
+ <title>Object oriented style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+if ($stmt = $mysqli->prepare("SELECT Name FROM Country WHERE Name=? OR Code=?")) {
+
+ $marker = $stmt->param_count;
+ printf("Statement has %d markers.\n", $marker);
+
+ /* close statement */
+ $stmt->close();
+}
+
+/* close connection */
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+ </example>
+ <example>
+ <title>Procedural style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$link = mysqli_connect("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+if ($stmt = mysqli_prepare($link, "SELECT Name FROM Country WHERE Name=? OR Code=?"))
{
+
+ $marker = mysqli_param_count($stmt);
+ printf("Statement has %d markers.\n", $marker);
+
+ /* close statement */
+ mysqli_stmt_close($stmt);
+}
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+ </example>
+ <para>
+ The above examples would produce the following output:
+ </para>
+ <screen>
+<![CDATA[
+Statement has 2 markers.
+]]>
+ </screen>
+ </refsect1>
</refentry>
<!-- Keep this comment at the end of the file
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-ping.xml?r1=1.3&r2=1.4&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-ping.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-ping.xml:1.3
phpdoc/en/reference/mysqli/functions/mysqli-ping.xml:1.4
--- phpdoc/en/reference/mysqli/functions/mysqli-ping.xml:1.3 Wed Jan 28 18:18:42
2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-ping.xml Thu Feb 26 09:48:54
2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<refentry id="function.mysqli-ping">
<refnamediv>
<refname>mysqli_ping</refname>
@@ -12,30 +12,94 @@
<title>Description</title>
<para>Procedural style:</para>
<methodsynopsis>
- <type>int</type><methodname>mysqli_ping</methodname>
+ <type>bool</type><methodname>mysqli_ping</methodname>
<methodparam><type>object</type><parameter>link</parameter></methodparam>
</methodsynopsis>
<para>Object oriented style (method):</para>
<classsynopsis>
<ooclass><classname>mysqli</classname></ooclass>
<methodsynopsis>
- <type>int</type><methodname>ping</methodname>
+ <type>bool</type><methodname>ping</methodname>
<methodparam><type>void</type><parameter></parameter></methodparam>
</methodsynopsis>
</classsynopsis>
<para>
Checks whether the connection to the server is working. If it has gone
- down, an automatic reconnection is attempted.
+ down, and global option <literal>mysqli.reconnect</literal> is enabled
+ an automatic reconnection is attempted.
</para>
<para>
This function can be used by clients that remain idle for a long while,
to check whether the server has closed the connection and reconnect if
necessary.
</para>
+ </refsect1>
+ <refsect1>
+ <title>Return values</title>
+ <para>&return.success;</para>
+ </refsect1>
+ <refsect1>
+ <title>Example</title>
+ <example>
+ <title>Object oriented style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* check if server is alive */
+if ($mysqli->ping()) {
+ printf ("Our connection is ok!\n");
+} else {
+ printf ("Error: %s\n", $mysqli->error);
+}
+
+/* close connection */
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+ </example>
+ <example>
+ <title>Procedural style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$link = mysqli_connect("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* check if server is alive */
+if (mysqli_ping($link)) {
+ printf ("Our connection is ok!\n");
+} else {
+ printf ("Error: %s\n", mysqli_error($link));
+}
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+ </example>
<para>
- <function>mysqli_ping</function> returns 0 if the connection is alive
- and non-zero value if an error has occured.
+ The above examples would produce the following output:
</para>
+ <screen>
+<![CDATA[
+Our connection is ok!
+]]>
+ </screen>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-prepare.xml?r1=1.3&r2=1.4&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-prepare.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-prepare.xml:1.3
phpdoc/en/reference/mysqli/functions/mysqli-prepare.xml:1.4
--- phpdoc/en/reference/mysqli/functions/mysqli-prepare.xml:1.3 Wed Jan 28 18:18:42
2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-prepare.xml Thu Feb 26 09:48:54
2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<refentry id="function.mysqli-prepare">
<refnamediv>
<refname>mysqli_prepare</refname>
@@ -80,6 +80,101 @@
<function>mysqli_stmt_close</function>
</para>
</refsect1>
+ <refsect1>
+ <title>Example</title>
+ <example>
+ <title>Object oriented style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+$city = "Amersfoort";
+
+/* create a prepared statement */
+if ($stmt = $mysqli->prepare("SELECT District FROM City WHERE Name=?")) {
+
+ /* bind parameters for markers */
+ $stmt->bind_param("s", $city);
+
+ /* execute query */
+ $stmt->execute();
+
+ /* bind result variables */
+ $stmt->bind_result($district);
+
+ /* fetch value */
+ $stmt->fetch();
+
+ printf("%s is in district %s\n", $city, $district);
+
+ /* close statement */
+ $stmt->close();
+}
+
+/* close connection */
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+ </example>
+ <example>
+ <title>Procedural style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$link = mysqli_connect("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+$city = "Amersfoort";
+
+/* create a prepared statement */
+if ($stmt = mysqli_prepare($link, "SELECT District FROM City WHERE Name=?")) {
+
+ /* bind parameters for markers */
+ mysqli_bind_param($stmt, "s", $city);
+
+ /* execute query */
+ mysqli_execute($stmt);
+
+ /* bind result variables */
+ mysqli_bind_result($stmt, $district);
+
+ /* fetch value */
+ mysqli_fetch($stmt);
+
+ printf("%s is in district %s\n", $city, $district);
+
+ /* close statement */
+ mysqli_stmt_close($stmt);
+}
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+ </example>
+ <para>
+ The above examples would produce the following output:
+ </para>
+ <screen>
+<![CDATA[
+Amersfoort is in district Utrecht
+]]>
+ </screen>
+ </refsect1>
</refentry>
<!-- Keep this comment at the end of the file
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-query.xml?r1=1.5&r2=1.6&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-query.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-query.xml:1.5
phpdoc/en/reference/mysqli/functions/mysqli-query.xml:1.6
--- phpdoc/en/reference/mysqli/functions/mysqli-query.xml:1.5 Wed Jan 28 18:18:42
2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-query.xml Thu Feb 26 09:48:54
2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.5 $ -->
+<!-- $Revision: 1.6 $ -->
<refentry id="function.mysqli-query">
<refnamediv>
<refname>mysqli_query</refname>
@@ -63,6 +63,105 @@
<function>mysqli_free_result</function>
</para>
</refsect1>
+ <refsect1>
+ <title>Example</title>
+ <example>
+ <title>Object oriented style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* Create table doesn't return a resultset */
+if ($mysqli->query("CREATE TEMPORARY TABLE myCity LIKE City") === TRUE) {
+ printf("Table myCity successfully created.\n");
+}
+
+/* Select queries return a resultset */
+if ($result = $mysqli->query("SELECT Name FROM City LIMIT 10")) {
+ printf("Select returned %d rows.\n", $result->num_rows);
+
+ /* free result set */
+ $result->close();
+}
+
+/* If we have to retrieve large amount of data we use MYSQLI_USE_RESULT */
+if ($result = $mysqli->query("SELECT * FROM City", MYSQLI_USE_RESULT)) {
+
+ /* Note, that we can't execute any functions which interact with the
+ server until result set was closed. All calls will return an
+ 'out of sync' error */
+ if (!$mysqli->query("SET @a:='this will not work'")) {
+ printf("Error: %s\n", $mysqli->error);
+ }
+ $result->close();
+}
+
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+ </example>
+ <example>
+ <title>Procedural style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$link = mysqli_connect("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* Create table doesn't return a resultset */
+if (mysqli_query($link, "CREATE TEMPORARY TABLE myCity LIKE City") === TRUE) {
+ printf("Table myCity successfully created.\n");
+}
+
+/* Select queries return a resultset */
+if ($result = mysqli_query($link, "SELECT Name FROM City LIMIT 10")) {
+ printf("Select returned %d rows.\n", mysqli_num_rows($result));
+
+ /* free result set */
+ mysqli_free_result($result);
+}
+
+/* If we have to retrieve large amount of data we use MYSQLI_USE_RESULT */
+if ($result = mysqli_query($link, "SELECT * FROM City", MYSQLI_USE_RESULT)) {
+
+ /* Note, that we can't execute any functions which interact with the
+ server until result set was closed. All calls will return an
+ 'out of sync' error */
+ if (!mysqli_query($link, "SET @a:='this will not work'")) {
+ printf("Error: %s\n", mysqli_error($link));
+ }
+ mysqli_free_result($result);
+}
+
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+ </example>
+ <para>
+ The above examples would produce the following output:
+ </para>
+ <screen>
+<![CDATA[
+Table myCity successfully created.
+Select returned 10 rows.
+Error: Commands out of sync; You can't run this command now
+]]>
+ </screen>
+ </refsect1>
</refentry>
<!-- Keep this comment at the end of the file
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-real-connect.xml?r1=1.4&r2=1.5&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-real-connect.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-real-connect.xml:1.4
phpdoc/en/reference/mysqli/functions/mysqli-real-connect.xml:1.5
--- phpdoc/en/reference/mysqli/functions/mysqli-real-connect.xml:1.4 Wed Jan 28
18:18:42 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-real-connect.xml Thu Feb 26
09:48:54 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
<refentry id="function.mysqli-real-connect">
<refnamediv>
<refname>mysqli_real_connect</refname>
@@ -117,6 +117,76 @@
<function>mysqli_close</function>.
</para>
</refsect1>
+ <refsect1>
+ <title>Example</title>
+ <example>
+ <title>Object oriented style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+/* create a connection object which is not connected */
+$mysqli = mysqli_init();
+
+/* set connection options */
+$mysqli->options(MYSQLI_INIT_COMMAND, "SET AUTOCOMMIT=0");
+$mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5);
+
+/* connect to server */
+$mysqli->real_connect('localhost', 'my_user', 'my_password', 'world');
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+printf ("Connection: %s\n.", $mysqli->host_info);
+
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+ </example>
+ <example>
+ <title>Procedural style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+/* create a connection object which is not connected */
+$link = mysqli_init();
+
+/* set connection options */
+mysqli_options($link, MYSQLI_INIT_COMMAND, "SET AUTOCOMMIT=0");
+mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 5);
+
+/* connect to server */
+mysqli_real_connect($link, 'localhost', 'my_user', 'my_password', 'world');
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+printf ("Connection: %s\n.", mysqli_get_host_info($link));
+
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+ </example>
+ <para>
+ The above examples would produce the following output:
+ </para>
+ <screen>
+<![CDATA[
+Connection: Localhost via UNIX socket
+
+]]>
+ </screen>
+ </refsect1>
</refentry>
<!-- Keep this comment at the end of the file