georg Fri Feb 27 04:22:17 2004 EDT
Modified files:
/phpdoc/en/reference/mysqli/functions mysqli-stat.xml
mysqli-stmt-affected-rows.xml
mysqli-stmt-data-seek.xml
mysqli-stmt-errno.xml
mysqli-stmt-error.xml
mysqli-stmt-sqlstate.xml
mysqli-stmt-num-rows.xml
mysqli-stmt-store-result.xml
mysqli-store-result.xml
mysqli-use-result.xml
mysqli-thread-id.xml
mysqli-warning-count.xml
Log:
added samples
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-stat.xml?r1=1.3&r2=1.4&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-stat.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-stat.xml:1.3
phpdoc/en/reference/mysqli/functions/mysqli-stat.xml:1.4
--- phpdoc/en/reference/mysqli/functions/mysqli-stat.xml:1.3 Wed Jan 28 18:18:42
2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-stat.xml Fri Feb 27 04:22:17
2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<refentry id="function.mysqli-stat">
<refnamediv>
<refname>mysqli_stat</refname>
@@ -10,14 +10,14 @@
<title>Description</title>
<para>Procedural style:</para>
<methodsynopsis>
- <type>string</type><methodname>mysqli_stat</methodname>
+ <type>mixed</type><methodname>mysqli_stat</methodname>
<methodparam><type>object</type><parameter>link</parameter></methodparam>
</methodsynopsis>
<para>Object oriented style (method):</para>
<classsynopsis>
<ooclass><classname>mysqli</classname></ooclass>
<methodsynopsis>
- <type>string</type><methodname>mysqli->stat</methodname>
+ <type>mixed</type><methodname>mysqli->stat</methodname>
<methodparam><type>void</type><parameter></parameter></methodparam>
</methodsynopsis>
</classsynopsis>
@@ -40,6 +40,59 @@
<function>mysqli_get_server_info</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();
+}
+
+printf ("System status: %s\n", $mysqli->stat());
+
+$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();
+}
+
+printf("System status: %s\n", mysqli_stat($link));
+
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+ </example>
+ <para>
+ The above examples would produce the following output:
+ </para>
+ <screen>
+<![CDATA[
+System status: Uptime: 272 Threads: 1 Questions: 5340 Slow queries: 0
+Opens: 13 Flush tables: 1 Open tables: 0 Queries per second avg: 19.632
+Memory in use: 8496K Max memory used: 8560K
+]]>
+ </screen>
+ </refsect1>
</refentry>
<!-- Keep this comment at the end of the file
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-stmt-affected-rows.xml?r1=1.3&r2=1.4&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-stmt-affected-rows.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-stmt-affected-rows.xml:1.3
phpdoc/en/reference/mysqli/functions/mysqli-stmt-affected-rows.xml:1.4
--- phpdoc/en/reference/mysqli/functions/mysqli-stmt-affected-rows.xml:1.3 Wed
Jan 28 18:18:42 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-stmt-affected-rows.xml Fri Feb 27
04:22:17 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<refentry id="function.mysqli-stmt-affected-rows">
<refnamediv>
<refname>mysqli_stmt_affected_rows</refname>
@@ -24,12 +24,6 @@
<function>mysqli_stmt_affected_rows</function> returns the number of rows
affected
by INSERT, UPDATE, or DELETE query. If the last query was invalid, this function
will return -1.
</para>
- <note>
- <para>
- For SELECT statements <function>mysqli_affected_rows</function> works like
- <function>mysqli_num_rows</function>.
- </para>
- </note>
<para>
The <function>mysqli_stmt_affected_rows</function> function only works with
queries
which update a table. In order to return the number of rows from a SELECT query,
use
@@ -58,6 +52,97 @@
<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();
+}
+
+/* create temp table */
+$mysqli->query("CREATE TEMPORARY TABLE myCountry LIKE Country");
+
+$query = "INSERT INTO myCountry SELECT * FROM Country WHERE Code LIKE ?";
+
+/* prepare statement */
+if ($stmt = $mysqli->prepare($query)) {
+
+ /* Bind variable for placeholder */
+ $code = 'A%';
+ $stmt->bind_param("s", $code);
+
+ /* execute statement */
+ $stmt->execute();
+
+ printf("rows inserted: %d\n", $stmt->affected_rows);
+
+ /* 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();
+}
+
+/* create temp table */
+mysqli_query($link, "CREATE TEMPORARY TABLE myCountry LIKE Country");
+
+$query = "INSERT INTO myCountry SELECT * FROM Country WHERE Code LIKE ?";
+
+/* prepare statement */
+if ($stmt = mysqli_prepare($link, $query)) {
+
+ /* Bind variable for placeholder */
+ $code = 'A%';
+ mysqli_bind_param($stmt, "s", $code);
+
+ /* execute statement */
+ mysqli_execute($stmt);
+
+ printf("rows inserted: %d\n", mysqli_stmt_affected_rows($stmt));
+
+ /* 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[
+rows inserted: 17
+]]>
+ </screen>
+ </refsect1>
</refentry>
<!-- Keep this comment at the end of the file
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-stmt-data-seek.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-stmt-data-seek.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-stmt-data-seek.xml:1.2
phpdoc/en/reference/mysqli/functions/mysqli-stmt-data-seek.xml:1.3
--- phpdoc/en/reference/mysqli/functions/mysqli-stmt-data-seek.xml:1.2 Sat Jan 31
05:46:53 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-stmt-data-seek.xml Fri Feb 27
04:22:17 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<refentry id="function.mysqli-stmt-data-seek">
<refnamediv>
<refname>mysqli_stmt_data_seek</refname>
@@ -42,6 +42,105 @@
<function>mysqli_prepare</function>
</para>
</refsect1>
+ <refsect1>
+ <title>Example</title>
+ <example>
+ <title>Object oriented style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+/* Open a connection */
+$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 Name, CountryCode FROM City ORDER BY Name";
+if ($stmt = $mysqli->prepare($query)) {
+
+ /* execute query */
+ $stmt->execute();
+
+ /* bind result variables */
+ $stmt->bind_result($name, $code);
+
+ /* store result */
+ $stmt->store_result();
+
+ /* seek to row no. 400 */
+ $stmt->data_seek(399);
+
+ /* fetch values */
+ $stmt->fetch();
+
+ printf ("City: %s Countrycode: %s\n", $name, $code);
+
+ /* close statement */
+ $stmt->close();
+}
+
+/* close connection */
+$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", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+$query = "SELECT Name, CountryCode FROM City ORDER BY Name";
+if ($stmt = mysqli_prepare($link, $query)) {
+
+ /* execute query */
+ mysqli_execute($stmt);
+
+ /* bind result variables */
+ mysqli_bind_result($stmt, $name, $code);
+
+ /* store result */
+ mysqli_stmt_store_result($stmt);
+
+ /* seek to row no. 400 */
+ mysqli_stmt_data_seek($stmt, 399);
+
+ /* fetch values */
+ mysqli_fetch($stmt);
+
+ printf ("City: %s Countrycode: %s\n", $name, $code);
+
+ /* 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[
+City: Benin City Countrycode: NGA
+]]>
+ </screen>
+ </refsect1>
</refentry>
<!-- Keep this comment at the end of the file
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-stmt-errno.xml?r1=1.3&r2=1.4&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-stmt-errno.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-stmt-errno.xml:1.3
phpdoc/en/reference/mysqli/functions/mysqli-stmt-errno.xml:1.4
--- phpdoc/en/reference/mysqli/functions/mysqli-stmt-errno.xml:1.3 Wed Jan 28
18:18:42 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-stmt-errno.xml Fri Feb 27 04:22:17
2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<refentry id="function.mysqli-stmt-errno">
<refnamediv>
<refname>mysqli_stmt_errno</refname>
@@ -19,7 +19,7 @@
<fieldsynopsis><type>int</type><varname>errno</varname></fieldsynopsis>
</classsynopsis>
<para>
- For the statement specified by <literal>stmt</literal>,
<function>mysqli_stmt_errno()</function>
+ For the statement specified by <literal>stmt</literal>,
<function>mysqli_stmt_errno</function>
returns the error code for the most recently invoked statement function that can
succeed or fail.
</para>
<note>
@@ -44,6 +44,95 @@
<function>mysqli_stmt_sqlstate</function>
</para>
</refsect1>
+ <refsect1>
+ <title>Example</title>
+ <example>
+ <title>Object oriented style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+/* Open a connection */
+$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+$mysqli->query("CREATE TABLE myCountry LIKE Country");
+$mysqli->query("INSERT INTO myCountry SELECT * FROM Country");
+
+
+$query = "SELECT Name, Code FROM myCountry ORDER BY Name";
+if ($stmt = $mysqli->prepare($query)) {
+
+ /* drop table */
+ $mysqli->query("DROP TABLE myCountry");
+
+ /* execute query */
+ $stmt->execute();
+
+ printf("Error: %d.\n", $stmt->errno);
+
+ /* close statement */
+ $stmt->close();
+}
+
+/* close connection */
+$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", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+mysqli_query($link, "CREATE TABLE myCountry LIKE Country");
+mysqli_query($link, "INSERT INTO myCountry SELECT * FROM Country");
+
+
+$query = "SELECT Name, Code FROM myCountry ORDER BY Name";
+if ($stmt = mysqli_prepare($link, $query)) {
+
+ /* drop table */
+ mysqli_query($link, "DROP TABLE myCountry");
+
+ /* execute query */
+ mysqli_execute($stmt);
+
+ printf("Error: %d.\n", mysqli_stmt_errno($stmt));
+
+ /* 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[
+Error: 1146.
+]]>
+ </screen>
+ </refsect1>
</refentry>
<!-- Keep this comment at the end of the file
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-stmt-error.xml?r1=1.3&r2=1.4&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-stmt-error.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-stmt-error.xml:1.3
phpdoc/en/reference/mysqli/functions/mysqli-stmt-error.xml:1.4
--- phpdoc/en/reference/mysqli/functions/mysqli-stmt-error.xml:1.3 Wed Jan 28
18:18:42 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-stmt-error.xml Fri Feb 27 04:22:17
2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<refentry id="function.mysqli-stmt-error">
<refnamediv>
<refname>mysqli_stmt_error</refname>
@@ -37,7 +37,95 @@
<function>mysqli_stmt_sqlstate</function>
</para>
</refsect1>
+ <refsect1>
+ <title>Example</title>
+ <example>
+ <title>Object oriented style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+/* Open a connection */
+$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+$mysqli->query("CREATE TABLE myCountry LIKE Country");
+$mysqli->query("INSERT INTO myCountry SELECT * FROM Country");
+
+
+$query = "SELECT Name, Code FROM myCountry ORDER BY Name";
+if ($stmt = $mysqli->prepare($query)) {
+
+ /* drop table */
+ $mysqli->query("DROP TABLE myCountry");
+
+ /* execute query */
+ $stmt->execute();
+
+ printf("Error: %s.\n", $stmt->error);
+
+ /* close statement */
+ $stmt->close();
+}
+
+/* close connection */
+$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", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+mysqli_query($link, "CREATE TABLE myCountry LIKE Country");
+mysqli_query($link, "INSERT INTO myCountry SELECT * FROM Country");
+
+
+$query = "SELECT Name, Code FROM myCountry ORDER BY Name";
+if ($stmt = mysqli_prepare($link, $query)) {
+
+ /* drop table */
+ mysqli_query($link, "DROP TABLE myCountry");
+
+ /* execute query */
+ mysqli_execute($stmt);
+
+ printf("Error: %s.\n", mysqli_stmt_error($stmt));
+
+ /* 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[
+Error: Table 'world.myCountry' doesn't exist.
+]]>
+ </screen>
+ </refsect1>
</refentry>
<!-- Keep this comment at the end of the file
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-stmt-sqlstate.xml?r1=1.1&r2=1.2&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-stmt-sqlstate.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-stmt-sqlstate.xml:1.1
phpdoc/en/reference/mysqli/functions/mysqli-stmt-sqlstate.xml:1.2
--- phpdoc/en/reference/mysqli/functions/mysqli-stmt-sqlstate.xml:1.1 Sun Feb 8
08:14:42 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-stmt-sqlstate.xml Fri Feb 27
04:22:17 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
<refentry id="function.mysqli-stmt-sqlstate">
<refnamediv>
<refname>mysqli_stmt_sqlstate</refname>
@@ -7,13 +7,126 @@
</refnamediv>
<refsect1>
<title>Description</title>
- <methodsynopsis>
- <type>string</type><methodname>mysqli_stmt_sqlstate</methodname>
- <methodparam><type>object</type><parameter>stmt</parameter></methodparam>
- </methodsynopsis>
+ <methodsynopsis>
+ <type>string</type><methodname>mysqli_stmt_sqlstate</methodname>
+ <methodparam><type>object</type><parameter>stmt</parameter></methodparam>
+ </methodsynopsis>
+ <para>
+ Returns a string containing the SQLSTATE error code
+ for the most recently invoked prepared statement function that can succeed or
fail.
+ The error code consists of five characters. <literal>'00000'</literal> means no
error.
+ The values are specified by ANSI SQL and ODBC. For a list of possible values,
see
+ <ulink url="&url.mysql.docs.error;">&url.mysql.docs.error;</ulink>.
+ </para>
+ <note>
+ <para>
+ Note that not all MySQL errors are yet mapped to SQLSTATE's.
+ The value <literal>HY000</literal> (general error) is used for unmapped errors.
+ </para>
+ </note>
+ </refsect1>
+ <refsect1>
+ <title>Return values</title>
+ <para>
+ Returns a string containing the SQLSTATE error code for the last error.
+ The error code consists of five characters. <literal>'00000'</literal> means no
error.
+ </para>
+ </refsect1>
+ <refsect1>
+ <title>See also</title>
+ <para>
+ <function>mysqli_stmt_errno</function>,
+ <function>mysqli_stmt_error</function>
+ </para>
+ </refsect1>
+ <refsect1>
+ <title>Example</title>
+ <example>
+ <title>Object oriented style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+/* Open a connection */
+$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+$mysqli->query("CREATE TABLE myCountry LIKE Country");
+$mysqli->query("INSERT INTO myCountry SELECT * FROM Country");
+
+
+$query = "SELECT Name, Code FROM myCountry ORDER BY Name";
+if ($stmt = $mysqli->prepare($query)) {
+
+ /* drop table */
+ $mysqli->query("DROP TABLE myCountry");
+
+ /* execute query */
+ $stmt->execute();
+
+ printf("Error: %s.\n", $stmt->sqlstate);
+
+ /* close statement */
+ $stmt->close();
+}
+
+/* close connection */
+$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", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+mysqli_query($link, "CREATE TABLE myCountry LIKE Country");
+mysqli_query($link, "INSERT INTO myCountry SELECT * FROM Country");
+
+
+$query = "SELECT Name, Code FROM myCountry ORDER BY Name";
+if ($stmt = mysqli_prepare($link, $query)) {
+
+ /* drop table */
+ mysqli_query($link, "DROP TABLE myCountry");
+
+ /* execute query */
+ mysqli_execute($stmt);
+
+ printf("Error: %s.\n", mysqli_stmt_sqlstate($stmt));
- &warn.undocumented.func;
+ /* 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[
+Error: 42S02.
+]]>
+ </screen>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-stmt-num-rows.xml?r1=1.1&r2=1.2&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-stmt-num-rows.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-stmt-num-rows.xml:1.1
phpdoc/en/reference/mysqli/functions/mysqli-stmt-num-rows.xml:1.2
--- phpdoc/en/reference/mysqli/functions/mysqli-stmt-num-rows.xml:1.1 Sun Feb 8
08:38:38 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-stmt-num-rows.xml Fri Feb 27
04:22:17 2004
@@ -1,19 +1,127 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
<refentry id="function.mysqli-stmt-num-rows">
<refnamediv>
<refname>mysqli_stmt_num_rows</refname>
+ <refname>stmt->num_rows</refname>
<refpurpose>Return the number of rows in statements result set.</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
- <methodsynopsis>
- <type>mixed</type><methodname>mysqli_stmt_num_rows</methodname>
- <methodparam><type>object</type><parameter>stmt</parameter></methodparam>
- </methodsynopsis>
+ <methodsynopsis>
+ <type>mixed</type><methodname>mysqli_stmt_num_rows</methodname>
+ <methodparam><type>object</type><parameter>stmt</parameter></methodparam>
+ </methodsynopsis>
+ <classsynopsis>
+ <ooclass><classname>stmt</classname></ooclass>
+ <fieldsynopsis><type>int</type><varname>num_rows</varname></fieldsynopsis>
+ </classsynopsis>
+ <para>
+ Returns the number of rows in the result set.
+ The use of <function>mysqli_stmt_num_rows</function>
+ depends on whether or not you used
+ <function>mysqli_stmt_store_result</function> to buffer the entire result
+ set in the statement handle.
+ </para>
+ <para>
+ If you use <function>mysqli_stmt_store_result</function>,
+ <function>mysqli_stmt_num_rows</function> may be called immediately.
+ </para>
+ </refsect1>
+ <refsect1>
+ <title>Return values</title>
+ <para>
+ An integer representing the number of rows in result set.
+ </para>
+ </refsect1>
+ <refsect1>
+ <title>See also</title>
+ <para>
+ <function>mysqli_stmt_affected_rows</function>,
+ <function>mysqli_prepare</function>,
+ <function>mysqli_stmt_store_result</function>
+ </para>
+ </refsect1>
+ <refsect1>
+ <title>Example</title>
+ <example>
+ <title>Object oriented style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+/* Open a connection */
+$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 Name, CountryCode FROM City ORDER BY Name LIMIT 20";
+if ($stmt = $mysqli->prepare($query)) {
+
+ /* execute query */
+ $stmt->execute();
+
+ /* store result */
+ $stmt->store_result();
+
+ printf("Number of rows: %d.\n", $stmt->num_rows);
+
+ /* close statement */
+ $stmt->close();
+}
+
+/* close connection */
+$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", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+$query = "SELECT Name, CountryCode FROM City ORDER BY Name LIMIT 20";
+if ($stmt = mysqli_prepare($link, $query)) {
+
+ /* execute query */
+ mysqli_execute($stmt);
+
+ /* store result */
+ mysqli_stmt_store_result($stmt);
+
+ printf("Number of rows: %d.\n", mysqli_stmt_num_rows($stmt));
- &warn.undocumented.func;
+ /* 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[
+Number of rows: 20.
+]]>
+ </screen>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-stmt-store-result.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-stmt-store-result.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-stmt-store-result.xml:1.2
phpdoc/en/reference/mysqli/functions/mysqli-stmt-store-result.xml:1.3
--- phpdoc/en/reference/mysqli/functions/mysqli-stmt-store-result.xml:1.2 Wed
Jan 28 18:18:42 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-stmt-store-result.xml Fri Feb 27
04:22:17 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<refentry id="function.mysqli-stmt-store-result">
<refnamediv>
<refname>mysqli_stmt_store_result</refname>
@@ -29,7 +29,7 @@
</para>
<note>
<para>
- It is unnecessary to call <function>mysql_stmt_store_result()</function> for
other queries,
+ It is unnecessary to call <function>mysql_stmt_store_result</function> for
other queries,
but if you do, it will not harm or cause any notable performance in all cases.
You can detect whether the query produced a result set by checking if
<function>mysql_get_metadata</function> returns NULL.
@@ -48,6 +48,87 @@
<function>mysqli_fetch</function>
</para>
</refsect1>
+ <refsect1>
+ <title>Example</title>
+ <example>
+ <title>Object oriented style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+/* Open a connection */
+$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 Name, CountryCode FROM City ORDER BY Name LIMIT 20";
+if ($stmt = $mysqli->prepare($query)) {
+
+ /* execute query */
+ $stmt->execute();
+
+ /* store result */
+ $stmt->store_result();
+
+ printf("Number of rows: %d.\n", $stmt->num_rows);
+
+ /* close statement */
+ $stmt->close();
+}
+
+/* close connection */
+$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", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+$query = "SELECT Name, CountryCode FROM City ORDER BY Name LIMIT 20";
+if ($stmt = mysqli_prepare($link, $query)) {
+
+ /* execute query */
+ mysqli_execute($stmt);
+
+ /* store result */
+ mysqli_stmt_store_result($stmt);
+
+ printf("Number of rows: %d.\n", mysqli_stmt_num_rows($stmt));
+
+ /* 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[
+Number of rows: 20.
+]]>
+ </screen>
+ </refsect1>
</refentry>
<!-- Keep this comment at the end of the file
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-store-result.xml?r1=1.5&r2=1.6&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-store-result.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-store-result.xml:1.5
phpdoc/en/reference/mysqli/functions/mysqli-store-result.xml:1.6
--- phpdoc/en/reference/mysqli/functions/mysqli-store-result.xml:1.5 Wed Jan 28
18:18:42 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-store-result.xml Fri Feb 27
04:22:17 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.5 $ -->
+<!-- $Revision: 1.6 $ -->
<refentry id="function.mysqli-store-result">
<refnamediv>
<refname>mysqli_store_result</refname>
@@ -65,6 +65,12 @@
<function>mysqli_use_result</function>.
</para>
</refsect1>
+ <refsect1>
+ <title>Example</title>
+ <para>
+ See <function>mysqli_multi_query</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-use-result.xml?r1=1.6&r2=1.7&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-use-result.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-use-result.xml:1.6
phpdoc/en/reference/mysqli/functions/mysqli-use-result.xml:1.7
--- phpdoc/en/reference/mysqli/functions/mysqli-use-result.xml:1.6 Wed Jan 28
18:18:42 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-use-result.xml Fri Feb 27 04:22:17
2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.6 $ -->
+<!-- $Revision: 1.7 $ -->
<refentry id="function.mysqli-use-result">
<refnamediv>
<refname>mysqli_use_result</refname>
@@ -58,6 +58,101 @@
<function>mysqli_store_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();
+}
+
+$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->use_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_use_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
@@ -80,3 +175,24 @@
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:1
+sgml-indent-data:t
+indent-tabs-mode:nil
+sgml-parent-document:nil
+sgml-default-dtd-file:"../../../../manual.ced"
+sgml-exposed-tags:nil
+sgml-local-catalogs:nil
+sgml-local-ecat-files:nil
+End:
+vim600: syn=xml fen fdm=syntax fdl=2 si
+vim: et tw=78 syn=sgml
+vi: ts=1 sw=1
+-->
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-thread-id.xml?r1=1.4&r2=1.5&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-thread-id.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-thread-id.xml:1.4
phpdoc/en/reference/mysqli/functions/mysqli-thread-id.xml:1.5
--- phpdoc/en/reference/mysqli/functions/mysqli-thread-id.xml:1.4 Wed Jan 28
18:18:42 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-thread-id.xml Fri Feb 27 04:22:17
2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
<refentry id="function.mysqli-thread-id">
<refnamediv>
<refname>mysqli_thread_id</refname>
@@ -48,6 +48,79 @@
<function>mysqli_kill</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();
+}
+
+/* determine our thread id */
+$thread_id = $mysqli->thread_id;
+
+/* Kill connection */
+$mysqli->kill($thread_id);
+
+/* This should produce an error */
+if (!$mysqli->query("CREATE TABLE myCity LIKE City")) {
+ printf("Error: %s\n", $mysqli->error);
+ exit;
+}
+
+/* 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();
+}
+
+/* determine our thread id */
+$thread_id = mysqli_thread_id($link);
+
+/* Kill connection */
+mysqli_kill($link, $thread_id);
+
+/* This should produce an error */
+if (!mysqli_query($link, "CREATE TABLE myCity LIKE City")) {
+ printf("Error: %s\n", mysqli_error($link));
+ exit;
+}
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+ </example>
+ <para>
+ The above examples would produce the following output:
+ </para>
+ <screen>
+<![CDATA[
+Error: MySQL server has gone away
+]]>
+ </screen>
+ </refsect1>
</refentry>
<!-- Keep this comment at the end of the file
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-warning-count.xml?r1=1.4&r2=1.5&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-warning-count.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-warning-count.xml:1.4
phpdoc/en/reference/mysqli/functions/mysqli-warning-count.xml:1.5
--- phpdoc/en/reference/mysqli/functions/mysqli-warning-count.xml:1.4 Wed Jan 28
18:18:42 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-warning-count.xml Fri Feb 27
04:22:17 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
<refentry id="function.mysqli-warning-count">
<refnamediv>
<refname>mysqli_warning_count</refname>
@@ -44,6 +44,87 @@
<function>mysqli_sqlstate</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();
+}
+
+$mysqli->query("CREATE TABLE myCity LIKE City");
+
+/* a remarkable city in Wales */
+$query = "INSERT INTO myCity (CountryCode, Name) VALUES('GBR',
+ 'Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch')";
+
+$mysqli->query($query);
+
+if ($mysqli->warning_count) {
+ if ($result = $mysqli->query("SHOW WARNINGS")) {
+ $row = $result->fetch_row();
+ printf("%s (%d): %s\n", $row[0], $row[1], $row[2]);
+ $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();
+}
+
+mysqli_query($link, "CREATE TABLE myCity LIKE City");
+
+/* a remarkable long city name in Wales */
+$query = "INSERT INTO myCity (CountryCode, Name) VALUES('GBR',
+ 'Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch')";
+
+mysqli_query($link, $query);
+
+if (mysqli_warning_count($link)) {
+ if ($result = mysqli_query($link, "SHOW WARNINGS")) {
+ $row = mysqli_fetch_row($result);
+ printf("%s (%d): %s\n", $row[0], $row[1], $row[2]);
+ mysqli_free_result($result);
+ }
+}
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+ </example>
+ <para>
+ The above examples would produce the following output:
+ </para>
+ <screen>
+<![CDATA[
+Warning (1264): Data truncated for column 'Name' at row 1
+]]>
+ </screen>
+ </refsect1>
</refentry>
<!-- Keep this comment at the end of the file