georg Thu Feb 19 11:27:40 2004 EDT
Modified files:
/phpdoc/en/reference/mysqli/functions mysqli-affected-rows.xml
mysqli-autocommit.xml
mysqli-bind-param.xml
mysqli-bind-result.xml
mysqli-change-user.xml
Log:
added and fixed samples
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-affected-rows.xml?r1=1.12&r2=1.13&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-affected-rows.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-affected-rows.xml:1.12
phpdoc/en/reference/mysqli/functions/mysqli-affected-rows.xml:1.13
--- phpdoc/en/reference/mysqli/functions/mysqli-affected-rows.xml:1.12 Wed Jan 28
18:18:42 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-affected-rows.xml Thu Feb 19
11:27:40 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.12 $ -->
+<!-- $Revision: 1.13 $ -->
<refentry id="function.mysqli-affected-rows">
<refnamediv>
<refname>mysqli_affected_rows</refname>
@@ -51,84 +51,83 @@
</note>
</refsect1>
<refsect1>
+ <title>See also</title>
+ <para>
+ <function>mysqli_num_rows</function>,
+ <function>mysqli_info</function>.
+ </para>
+ </refsect1>
+ <refsect1>
<title>Example</title>
<para>
<example>
- <title>Example for affected rows</title>
+ <title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
- <?php
- /*
- +-----------------------------------------------------------+
- | file: mysqli_affected_rows.php |
- +-----------------------------------------------------------+
- | modifies some datasets and returns number of affected |
- | rows |
- +-----------------------------------------------------------+
- */
-
- /* ---- Procedural style ---- */
- $link = mysqli_connect("localhost", "my_user", "my_password", "test")
- or die("Can't connect to MySQL server on localhost");
-
- /* create table and insert some data */
- mysqli_query($link, "DROP TABLE IF EXISTS affected_rows");
- mysqli_query($link, "CREATE TABLE affected_rows (a int)");
- mysqli_query($link, "INSERT INTO affected_rows VALUES (1),(2),(3),(4)");
-
- /* update values and retrieve number of affected rows */
- mysqli_query($link, "UPDATE affected_rows SET a=5 WHERE a=1");
- printf("Affected rows (update): %d\n", mysqli_affected_rows($link));
-
- /* delete rows and retrieve number of affected_rows */
- mysqli_query($link, "DELETE FROM affected_rows WHERE a < 4");
- printf("Affected rows (delete): %d\n", mysqli_affected_rows($link));
-
- /* select all rows and retrieve number of affected_rows */
- mysqli_query($link, "SELECT a FROM affected_rows");
- printf("Affected rows (select): %d\n", mysqli_affected_rows($link));
-
- mysqli_close($link);
-
- /* ---- Object oriented style ----*/
- $mysqli = new mysqli("localhost", "my_user", "my_password", "test");
-
- if (mysqli_connect_errno()) {
- printf("Connect failed: %s\n", mysqli_connect_error());
- exit();
- }
-
- /* create table and insert some data */
- $mysqli->query("DROP TABLE IF EXISTS affected_rows");
- $mysqli->query("CREATE TABLE affected_rows (a int)");
- $mysqli->query("INSERT INTO affected_rows VALUES (1),(2),(3),(4)");
-
- /* update values and retrieve number of affected rows */
- $mysqli->query("UPDATE affected_rows SET a=5 WHERE a=1");
- printf("Affected rows (update): %d\n", $mysqli->affected_rows);
-
- /* delete rows and retrieve number of affected_rows */
- $mysqli->query("DELETE FROM affected_rows WHERE a < 4");
- printf("Affected rows (delete): %d\n", $mysqli->affected_rows);
-
- /* select all rows and retrieve number of affected_rows */
- $mysqli->query("SELECT a FROM affected_rows");
- printf("Affected rows (select): %d\n", $mysqli->affected_rows);
+<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
- $mysqli->close();
- ?>
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* create table and insert some data */
+$mysqli->query("DROP TABLE IF EXISTS affected_rows");
+$mysqli->query("CREATE TABLE affected_rows (a int)");
+$mysqli->query("INSERT INTO affected_rows VALUES (1),(2),(3),(4)");
+
+/* update values and retrieve number of affected rows */
+$mysqli->query("UPDATE affected_rows SET a=5 WHERE a=1");
+printf("Affected rows (update): %d\n", $mysqli->affected_rows);
+
+/* delete rows and retrieve number of affected_rows */
+$mysqli->query("DELETE FROM affected_rows WHERE a < 4");
+printf("Affected rows (delete): %d\n", $mysqli->affected_rows);
+
+/* select all rows and retrieve number of affected_rows */
+$mysqli->query("SELECT a FROM affected_rows");
+printf("Affected rows (select): %d\n", $mysqli->affected_rows);
+
+/* 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")
+ or die("Can't connect to MySQL server on localhost");
+
+/* create table and insert some data */
+mysqli_query($link, "DROP TABLE IF EXISTS affected_rows");
+mysqli_query($link, "CREATE TABLE affected_rows (a int)");
+mysqli_query($link, "INSERT INTO affected_rows VALUES (1),(2),(3),(4)");
+
+/* update values and retrieve number of affected rows */
+mysqli_query($link, "UPDATE affected_rows SET a=5 WHERE a=1");
+printf("Affected rows (update): %d\n", mysqli_affected_rows($link));
+
+/* delete rows and retrieve number of affected_rows */
+mysqli_query($link, "DELETE FROM affected_rows WHERE a < 4");
+printf("Affected rows (delete): %d\n", mysqli_affected_rows($link));
+
+/* select all rows and retrieve number of affected_rows */
+mysqli_query($link, "SELECT a FROM affected_rows");
+printf("Affected rows (select): %d\n", mysqli_affected_rows($link));
+
+/* close connection */
+mysqli_close($link);
+?>
]]>
</programlisting>
</example>
</para>
</refsect1>
- <refsect1>
- <title>See also</title>
- <para>
- <function>mysqli_num_rows</function>,
- <function>mysqli_info</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-autocommit.xml?r1=1.11&r2=1.12&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-autocommit.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-autocommit.xml:1.11
phpdoc/en/reference/mysqli/functions/mysqli-autocommit.xml:1.12
--- phpdoc/en/reference/mysqli/functions/mysqli-autocommit.xml:1.11 Wed Jan 28
18:18:42 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-autocommit.xml Thu Feb 19 11:27:40
2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.11 $ -->
+<!-- $Revision: 1.12 $ -->
<refentry id="function.mysqli-autocommit">
<refnamediv>
<refname>mysqli_autocommit</refname>
@@ -46,70 +46,67 @@
</para>
</refsect1>
<refsect1>
+ <title>See also</title>
+ <para>
+ <function>mysqli_commit</function>,
+ <function>mysqli_rollback</function>.
+ </para>
+ </refsect1>
+ <refsect1>
<title>Example</title>
<para>
<example>
- <title>Using the mysqli_autocommit function</title>
+ <title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
-/*
- +-----------------------------------------------------------+
- | file: mysqli_autocommit.php |
- +-----------------------------------------------------------+
- | connects to MySQL server on localhost, turns autocommit |
- | on and retrieves autocommit variable |
- +-----------------------------------------------------------+
-*/
-
- /* ---- Procedural style ---- */
- $link = mysqli_connect("localhost", "my_user", "my_password", "test")
- or die("Can't connect to MySQL server on localhost");
-
- /* turn autocommit on */
- mysqli_autocommit($link, TRUE);
-
- if ($result = mysqli_query($link, "SELECT @@autocommit")) {
- $row = mysqli_fetch_row($result);
- printf("Autocommit is %s\n", $row[0]);
- mysqli_free_result($result);
- }
-
- mysqli_close($link);
-
- /* ---- Object oriented style ----*/
- $mysqli = new mysqli("localhost", "my_user", "my_password", "test");
-
- if (mysqli_connect_errno()) {
- printf("Connect failed: %s\n", mysqli_connect_error());
- exit();
- }
-
- /* turn autocommit on */
- $mysqli->autocommit(TRUE);
-
- if ($result = $mysqli->query("SELECT @@autocommit")) {
- $row = $result->fetch_row();
- printf("Autocommit is %s\n", $row[0]);
- $result->free();
- }
+$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
+
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+exit();
+}
+
+/* turn autocommit on */
+$mysqli->autocommit(TRUE);
+
+if ($result = $mysqli->query("SELECT @@autocommit")) {
+ $row = $result->fetch_row();
+ printf("Autocommit is %s\n", $row[0]);
+ $result->free();
+}
- $mysqli->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", "test")
+ or die("Can't connect to MySQL server on localhost");
+/* turn autocommit on */
+mysqli_autocommit($link, TRUE);
+
+if ($result = mysqli_query($link, "SELECT @@autocommit")) {
+ $row = mysqli_fetch_row($result);
+ printf("Autocommit is %s\n", $row[0]);
+ mysqli_free_result($result);
+}
+
+/* close connection */
+mysqli_close($link);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
- <refsect1>
- <title>See also</title>
- <para>
- <function>mysqli_commit</function>,
- <function>mysqli_rollback</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-bind-param.xml?r1=1.5&r2=1.6&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-bind-param.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-bind-param.xml:1.5
phpdoc/en/reference/mysqli/functions/mysqli-bind-param.xml:1.6
--- phpdoc/en/reference/mysqli/functions/mysqli-bind-param.xml:1.5 Wed Feb 11
03:10:47 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-bind-param.xml Thu Feb 19 11:27:40
2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.5 $ -->
+<!-- $Revision: 1.6 $ -->
<refentry id="function.mysqli-bind-param">
<refnamediv>
<refname>mysqli_bind_param</refname>
@@ -83,74 +83,80 @@
</para>
</refsect1>
<refsect1>
+ <title>See also</title>
+ <para>
+ <function>mysqli_bind_result</function>,
+ <function>mysqli_execute</function>,
+ <function>mysqli_fetch</function>,
+<!-- <function>mysqli_fetch_column</function> -->
+ <function>mysqli_prepare</function>,
+ <function>mysqli_send_long_data</function>,
+ <function>mysqli_stmt_errno</function>,
+ <function>mysqli_stmt_error</function>
+ </para>
+ </refsect1>
+ <refsect1>
<title>Example</title>
<example>
- <title>Prepared statements</title>
+ <title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
- /* --- procedural style --- */
- $link = mysqli_connect("localhost", "mysql_user", "mysql_password", "mydb") or
- die("Could not connect: " . mysqli_connect_error());
-
- /* create mytable */
- mysqli_query($link, "CREATE TABLE mytable (a int, b int, c varchar(30))");
+/* create mytable */
+$mysqli->query("DROP TABLE IF EXISTS mytable");
+$mysqli->query("CREATE TABLE mytable (a int, b int, c varchar(30))");
- /* prepare statement and bind variables for insert statements */
- $stmt = mysqli_prepare($link, "INSERT INTO mytable VALUES (?, ?, ?)");
- mysqli_bind_param("iis", $a, $b, $c);
-
- $a = 1;
- $b = 2;
- $c = "I prefer OpenSource software";
-
- /* execute prepared statement */
- mysqli_execute($stmt);
-
- /* close statement and connection */
- mysqli_close_stmt(stmt);
- mysqli_close(link);
-
- /* --- object oriented style --- */
- $mysql = new mysqli("localhost", "mysql_user", "mysql_password", "mydb");
+/* prepare statement and bind parameters */
+$stmt = $mysqli->prepare("INSERT INTO mytable VALUES (?, ?, ?)");
+$stmt->bind_param("iis", $a, $b, $c);
+
+$a = 1;
+$b = 2;
+$c = "I like PHP";
+
+/* execute prepared statement */
+$stmt->execute();
+
+/* close statement and connection */
+$stmt->close();
+$mysqli->close();
+]]>
+ </programlisting>
+ </example>
+ <example>
+ <title>Procedural style</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$link = mysqli_connect("localhost", "my_user", "my_password", "test") or
+die("Could not connect: " . mysqli_connect_error());
- /* create mytable */
- $mysql->query("CREATE TABLE mytable (a int, b int, c varchar(30))");
+/* create mytable */
+mysqli_query($link, "DROP TABLE IF EXISTS mytable");
+mysqli_query($link, "CREATE TABLE mytable (a int, b int, c varchar(30))");
- /* prepare statement and bind parameters */
- $stmt = $mysql->prepare("INSERT INTO mytable VALUES (?, ?, ?)");
- $stmt->bind_param("iis", $a, $b, $c);
-
- $a = 1;
- $b = 2;
- $c = "I prefer opensource software";
-
- /* execute prepared statement */
- $stmt->execute();
-
- /* close statement and connection */
- $stmt->close();
- $mysql->close();
+/* prepare statement and bind variables for insert statements */
+$stmt = mysqli_prepare($link, "INSERT INTO mytable VALUES (?, ?, ?)");
+mysqli_bind_param($stmt, "iis", $a, $b, $c);
+
+$a = 1;
+$b = 2;
+$c = "I like PHP";
+
+/* execute prepared statement */
+mysqli_execute($stmt);
+
+/* close statement and connection */
+mysqli_stmt_close($stmt);
+mysqli_close($link);
?>
]]>
</programlisting>
</example>
</refsect1>
- <refsect1>
- <title>See also</title>
- <para>
- <function>mysqli_bind_result</function>,
- <function>mysqli_execute</function>,
- <function>mysqli_fetch</function>,
-<!-- <function>mysqli_fetch_column</function> -->
- <function>mysqli_prepare</function>,
- <function>mysqli_send_long_data</function>,
- <function>mysqli_stmt_errno</function>,
- <function>mysqli_stmt_error</function>
- </para>
- </refsect1>
- </refentry>
+ </refentry>
<!-- Keep this comment at the end of the file
Local variables:
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-bind-result.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-bind-result.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-bind-result.xml:1.2
phpdoc/en/reference/mysqli/functions/mysqli-bind-result.xml:1.3
--- phpdoc/en/reference/mysqli/functions/mysqli-bind-result.xml:1.2 Wed Jan 28
18:18:42 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-bind-result.xml Thu Feb 19 11:27:40
2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<refentry id="function.mysqli-bind-result">
<refnamediv>
<refname>mysqli_bind_result</refname>
@@ -60,7 +60,88 @@
<function>mysqli_stmt_error</function>
</para>
</refsect1>
- </refentry>
+ <refsect1>
+ <title>Example</title>
+ <para>
+ <example>
+ <title>Object oriented style</title>
+ <programlisting role="php">
+ <![CDATA[
+<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
+
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* create table and insert some data */
+$mysqli->query("DROP TABLE IF EXISTS bind_result");
+$mysqli->query("CREATE TABLE bind_result (id int, extension varchar(20))");
+$mysqli->query("INSERT INTO bind_result VALUES (1, 'ldap')");
+$mysqli->query("INSERT INTO bind_result VALUES (2, 'mysql')");
+$mysqli->query("INSERT INTO bind_result VALUES (3, 'pcre')");
+
+/* prepare statement */
+if ($stmt = $mysqli->prepare("SELECT id, extension FROM bind_result")) {
+ $stmt->execute();
+
+ /* bind variables to prepared statement */
+ $stmt->bind_result($col1, $col2);
+
+ /* fetch values */
+ while ($stmt->fetch()) {
+ printf("Id: %d Extension: %s\n", $col1, $col2);
+ }
+ /* 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", "test")
+ or die("Can't connect to MySQL server on localhost");
+
+/* create table and insert some data */
+mysqli_query($link, "DROP TABLE IF EXISTS bind_result");
+mysqli_query($link, "CREATE TABLE bind_result (id int, extension varchar(20))");
+mysqli_query($link, "INSERT INTO bind_result VALUES (1, 'ldap')");
+mysqli_query($link, "INSERT INTO bind_result VALUES (2, 'mysql')");
+mysqli_query($link, "INSERT INTO bind_result VALUES (3, 'pcre')");
+
+/* prepare statement */
+if ($stmt = mysqli_prepare($link, "SELECT id, extension FROM bind_result")) {
+ mysqli_execute($stmt);
+
+ /* bind variables to prepared statement */
+ mysqli_bind_result($stmt, $col1, $col2);
+
+ /* fetch values */
+ while (mysqli_fetch($stmt)) {
+ printf("Id: %d Extension: %s\n", $col1, $col2);
+ }
+ /* close statement */
+ mysqli_stmt_close($stmt);
+}
+
+/* close connection */
+mysqli_close($link);
+?>
+ ]]>
+ </programlisting>
+ </example>
+ </para>
+ </refsect1>
+</refentry>
<!-- Keep this comment at the end of the file
Local variables:
http://cvs.php.net/diff.php/phpdoc/en/reference/mysqli/functions/mysqli-change-user.xml?r1=1.7&r2=1.8&ty=u
Index: phpdoc/en/reference/mysqli/functions/mysqli-change-user.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-change-user.xml:1.7
phpdoc/en/reference/mysqli/functions/mysqli-change-user.xml:1.8
--- phpdoc/en/reference/mysqli/functions/mysqli-change-user.xml:1.7 Wed Jan 28
18:18:42 2004
+++ phpdoc/en/reference/mysqli/functions/mysqli-change-user.xml Thu Feb 19 11:27:40
2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.7 $ -->
+<!-- $Revision: 1.8 $ -->
<refentry id="function.mysqli-change-user">
<refnamediv>
<refname>mysqli_change_user</refname>
@@ -59,21 +59,68 @@
</para>
</refsect1>
<refsect1>
+ <title>See also:</title>
+ <para>
+ <function>mysqli_connect</function>
+ <function>mysqli_select_db</function>
+ </para>
+ </refsect1>
+ <refsect1>
<title>Example</title>
<para>
<example>
- <title>Using the mysqli_change_user function</title>
+ <title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
-
- /* Open a connection as [EMAIL PROTECTED] and select foo_db */
- $link = mysqli_connect("localhost", "foo", "pass");
- mysqli_select_db("foo_db");
+
+$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
+
+$mysqli->query("CREATE TEMPORARY TABLE mytemp (a int)");
- /* Change user to [EMAIL PROTECTED] and default database to bar_db */
- mysqli_change_user($link, "bar", "otherpass", "bar_db");
+/* reset all */
+$mysqli->change_user("my_user", "my_password", NULL);
+
+if ($result = $mysqli->query("SELECT DATABASE()")) {
+ $row = $result->fetch_row();
+ printf("Default database: %s\n", $row[0]);
+ $result->close();
+}
+
+if (!($result = $mysqli->query("SHOW TABLES LIKE mytemp"))) {
+ printf ("temporary table mytemp doesn't exist\n");
+}
+
+/* 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, "CREATE TEMPORARY TABLE mytemp (a int)");
+
+/* reset all */
+mysqli_change_user($link, "my_user", "my_password", NULL);
+
+if ($result = mysqli_query($link, "SELECT DATABASE()")) {
+ $row = mysqli_fetch_row($result);
+ printf("Default database: %s\n", $row[0]);
+ mysqli_free_result($result);
+}
+
+if (!($result = mysqli_query($link, "SHOW TABLES LIKE mytemp"))) {
+ printf ("temporary table mytemp doesn't exist\n");
+}
+/* close connection */
+mysqli_close($link);
?>
]]>
</programlisting>