Minor update:

- changed/added samples
- all samples use world database now
- added url for world db in reference.xml
- added output for samples


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@152396 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Georg Richter 2004-02-25 21:59:16 +00:00
parent 72333363c2
commit 1e375cc8bd
30 changed files with 1614 additions and 840 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.13 $ -->
<!-- $Revision: 1.14 $ -->
<refentry id="function.mysqli-affected-rows">
<refnamediv>
<refname>mysqli_affected_rows</refname>
@ -59,74 +59,100 @@
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$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 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)");
/* Insert rows */
$mysqli->query("CREATE TABLE Language SELECT * from CountryLanguage");
printf("Affected rows (INSERT): %d\n", $mysqli->affected_rows);
/* 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);
$mysqli->query("ALTER TABLE Language ADD Status int default 0");
/* 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);
/* update rows */
$mysqli->query("UPDATE Language SET Status=1 WHERE Percentage > 50");
printf("Affected rows (UPDATE): %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);
/* delete rows */
$mysqli->query("DELETE FROM Language WHERE Percentage < 50");
printf("Affected rows (DELETE): %d\n", $mysqli->affected_rows);
/* select all rows */
$result = $mysqli->query("SELECT CountryCode FROM Language");
printf("Affected rows (SELECT): %d\n", $mysqli->affected_rows);
$result->close();
/* Delete table Language */
$mysqli->query("DROP TABLE Language");
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
]]>
</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");
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* 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)");
if (!$link) {
printf("Can't connect to localhost. Error: %s\n", mysqli_connect_error());
exit();
}
/* 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));
/* Insert rows */
mysqli_query($link, "CREATE TABLE Language SELECT * from CountryLanguage");
printf("Affected rows (INSERT): %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));
mysqli_query($link, "ALTER TABLE Language ADD Status int default 0");
/* 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));
/* update rows */
mysqli_query($link, "UPDATE Language SET Status=1 WHERE Percentage > 50");
printf("Affected rows (UPDATE): %d\n", mysqli_affected_rows($link));
/* delete rows */
mysqli_query($link, "DELETE FROM Language WHERE Percentage < 50");
printf("Affected rows (DELETE): %d\n", mysqli_affected_rows($link));
/* select all rows */
$result = mysqli_query($link, "SELECT CountryCode FROM Language");
printf("Affected rows (SELECT): %d\n", mysqli_affected_rows($link));
mysqli_free_result($result);
/* Delete table Language */
mysqli_query($link, "DROP TABLE Language");
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
]]>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Affected rows (INSERT): 984
Affected rows (UPDATE): 168
Affected rows (DELETE): 815
Affected rows (SELECT): 169
]]>
</screen>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.12 $ -->
<!-- $Revision: 1.13 $ -->
<refentry id="function.mysqli-autocommit">
<refnamediv>
<refname>mysqli_autocommit</refname>
@ -54,17 +54,16 @@
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
exit();
}
/* turn autocommit on */
@ -80,15 +79,19 @@ if ($result = $mysqli->query("SELECT @@autocommit")) {
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
</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");
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
if (!$link) {
printf("Can't connect to localhost. Error: %s\n", mysqli_connect_error());
exit();
}
/* turn autocommit on */
mysqli_autocommit($link, TRUE);
@ -103,9 +106,16 @@ if ($result = mysqli_query($link, "SELECT @@autocommit")) {
mysqli_close($link);
?>
]]>
</programlisting>
</example>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Autocommit is 1
]]>
</screen>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<!-- $Revision: 1.7 $ -->
<refentry id="function.mysqli-bind-param">
<refnamediv>
<refname>mysqli_bind_param</refname>
@ -88,7 +88,6 @@
<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>,
@ -97,66 +96,95 @@
</refsect1>
<refsect1>
<title>Example</title>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$mysqli = new mysqli('localhost', 'my_user', 'my_password', 'world');
/* 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 parameters */
$stmt = $mysqli->prepare("INSERT INTO mytable VALUES (?, ?, ?)");
$stmt->bind_param("iis", $a, $b, $c);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$a = 1;
$b = 2;
$c = "I like PHP";
$stmt = $mysqli->prepare("INSERT INTO CountryLanguage VALUES (?, ?, ?, ?)");
$stmt->bind_param('sssd', $code, $language, $official, $percent);
$code = 'DEU';
$language = 'Bavarian';
$official = "F";
$percent = 11.2;
/* execute prepared statement */
$stmt->execute();
printf("%d Row inserted.\n", $stmt->affected_rows);
/* close statement and connection */
$stmt->close();
/* Clean up table CountryLanguage */
$mysqli->query("DELETE FROM CountryLanguage WHERE Language='Bavarian'");
printf("%d Row deleted.\n", $mysqli->affected_rows);
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</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());
$link = mysqli_connect('localhost', 'my_user', 'my_password', 'world');
/* 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 variables for insert statements */
$stmt = mysqli_prepare($link, "INSERT INTO mytable VALUES (?, ?, ?)");
mysqli_bind_param($stmt, "iis", $a, $b, $c);
/* check connection */
if (!$link) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$a = 1;
$b = 2;
$c = "I like PHP";
$stmt = mysqli_prepare($link, "INSERT INTO CountryLanguage VALUES (?, ?, ?, ?)");
mysqli_bind_param($stmt, 'sssd', $code, $language, $official, $percent);
$code = 'DEU';
$language = 'Bavarian';
$official = "F";
$percent = 11.2;
/* execute prepared statement */
mysqli_execute($stmt);
printf("%d Row inserted.\n", mysqli_stmt_affected_rows($stmt));
/* close statement and connection */
mysqli_stmt_close($stmt);
/* Clean up table CountryLanguage */
mysqli_query($link, "DELETE FROM CountryLanguage WHERE Language='Bavarian'");
printf("%d Row deleted.\n", mysqli_affected_rows($link));
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
</refsect1>
</refentry>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
1 Row inserted.
1 Row deleted.
]]>
</screen>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<refentry id="function.mysqli-bind-result">
<refnamediv>
<refname>mysqli_bind_result</refname>
@ -62,28 +62,20 @@
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
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")) {
if ($stmt = $mysqli->prepare("SELECT Code, Name FROM Country ORDER BY Name LIMIT 5")) {
$stmt->execute();
/* bind variables to prepared statement */
@ -91,8 +83,9 @@ if ($stmt = $mysqli->prepare("SELECT id, extension FROM bind_result")) {
/* fetch values */
while ($stmt->fetch()) {
printf("Id: %d Extension: %s\n", $col1, $col2);
printf("%s %s\n", $col1, $col2);
}
/* close statement */
$stmt->close();
}
@ -100,26 +93,24 @@ if ($stmt = $mysqli->prepare("SELECT id, extension FROM bind_result")) {
$mysqli->close();
?>
]]>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
</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");
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* 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')");
/* check connection */
if (!$link) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* prepare statement */
if ($stmt = mysqli_prepare($link, "SELECT id, extension FROM bind_result")) {
if ($stmt = mysqli_prepare($link, "SELECT Code, Name FROM Country ORDER BY Name LIMIT 5")) {
mysqli_execute($stmt);
/* bind variables to prepared statement */
@ -127,8 +118,9 @@ if ($stmt = mysqli_prepare($link, "SELECT id, extension FROM bind_result")) {
/* fetch values */
while (mysqli_fetch($stmt)) {
printf("Id: %d Extension: %s\n", $col1, $col2);
printf("%s %s\n", $col1, $col2);
}
/* close statement */
mysqli_stmt_close($stmt);
}
@ -136,12 +128,23 @@ if ($stmt = mysqli_prepare($link, "SELECT id, extension FROM bind_result")) {
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
]]>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
AFG Afghanistan
ALB Albania
DZA Algeria
ASM American Samoa
AND Andorra
]]>
</screen>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.8 $ -->
<!-- $Revision: 1.9 $ -->
<refentry id="function.mysqli-change-user">
<refnamediv>
<refname>mysqli_change_user</refname>
@ -67,19 +67,26 @@
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
/* connect database test */
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$mysqli->query("CREATE TEMPORARY TABLE mytemp (a int)");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* Set Variable a */
$mysqli->query("SET @a:=1");
/* reset all */
$mysqli->change_user("my_user", "my_password", NULL);
/* reset all and select a new database */
$mysqli->change_user("my_user", "my_password", "world");
if ($result = $mysqli->query("SELECT DATABASE()")) {
$row = $result->fetch_row();
@ -87,8 +94,12 @@ if ($result = $mysqli->query("SELECT DATABASE()")) {
$result->close();
}
if (!($result = $mysqli->query("SHOW TABLES LIKE mytemp"))) {
printf ("temporary table mytemp doesn't exist\n");
if ($result = $mysqli->query("SELECT @a")) {
$row = $result->fetch_row();
if ($row[0] === NULL) {
printf("Value of variable a is NULL\n");
}
$result->close();
}
/* close connection */
@ -102,12 +113,20 @@ $mysqli->close();
<programlisting role="php">
<![CDATA[
<?php
/* connect database test */
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
mysqli_query($link, "CREATE TEMPORARY TABLE mytemp (a int)");
/* check connection */
if (!$link) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* Set Variable a */
mysqli_query($link, "SET @a:=1");
/* reset all */
mysqli_change_user($link, "my_user", "my_password", NULL);
/* reset all and select a new database */
mysqli_change_user($link, "my_user", "my_password", "world");
if ($result = mysqli_query($link, "SELECT DATABASE()")) {
$row = mysqli_fetch_row($result);
@ -115,17 +134,29 @@ if ($result = mysqli_query($link, "SELECT DATABASE()")) {
mysqli_free_result($result);
}
if (!($result = mysqli_query($link, "SHOW TABLES LIKE mytemp"))) {
printf ("temporary table mytemp doesn't exist\n");
if ($result = mysqli_query($link, "SELECT @a")) {
$row = mysqli_fetch_row($result);
if ($row[0] === NULL) {
printf("Value of variable a is NULL\n");
}
mysqli_free_result($result);
}
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Default database: world
Value of variable a is NULL
]]>
</screen>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.8 $ -->
<!-- $Revision: 1.9 $ -->
<refentry id="function.mysqli-character-set-name">
<refnamediv>
<refname>mysqli_character_set_name</refname>
@ -40,41 +40,61 @@
</refsect1>
<refsect1>
<title>Example</title>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
/* Open a connection */
$mysqli = new mysqli("localhost", "my_user", "my_password");
/* Open a connection */
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* Print current character set */
$charset = $mysqli->character_set_name();
printf ("Current character set is %s\n", $charset);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$mysqli->close();
/* 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">
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
/* Open a connection */
$link = mysqli_connect("localhost", "my_user", "my_password");
/* Open a connection */
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* Print current character set */
$charset = mysqli_character_set_name($link);
printf ("Current character set is %s\n",$charset);
/* check connection */
if (!$link) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* close connection */
mysqli_close($link);
/* 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>
<para>
The above examples would be produce the following output:
</para>
<screen>
<![CDATA[
Current character set is latin1_swedish_ci
]]>
</screen>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<refentry id="function.mysqli-commit">
<refnamediv>
<refname>mysqli_commit</refname>
@ -48,22 +48,29 @@
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$mysqli->query("DROP TABLE IF EXISTS ta_sample");
$mysqli->query("CREATE TABLE ta_sample (a int) TYPE=InnoDB");
$mysqli->query("CREATE TABLE Language LIKE CountryLanguage 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)");
$mysqli->query("INSERT INTO Language VALUES ('DEU', 'Bavarian', 'F', 11.2)");
$mysqli->query("INSERT INTO Language VALUES ('DEU', 'Swabian', 'F', 9.4)");
/* commit transaction */
$mysqli->commit();
/* drop table */
$mysqli->query("DROP TABLE Language");
/* close connection */
$mysqli->close();
?>
@ -75,18 +82,22 @@ $mysqli->close();
<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");
/* check connection */
if (!$link) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* set autocommit to off */
mysqli_autocommit($link, FALSE);
mysqli_query($link, "CREATE TABLE Language LIKE CountryLanguage Type=InnoDB");
/* Insert some values */
mysqli_query($link, "INSERT INTO ta_sample VALUES (1)");
mysqli_query($link, "INSERT INTO ta_sample VALUES (1)");
mysqli_query($link, "INSERT INTO Language VALUES ('DEU', 'Bavarian', 'F', 11.2)");
mysqli_query($link, "INSERT INTO Language VALUES ('DEU', 'Swabian', 'F', 9.4)");
/* commit transaction */
mysqli_commit($link);

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.10 $ -->
<!-- $Revision: 1.11 $ -->
<refentry id="function.mysqli-connect">
<refnamediv>
<refname>mysqli_connect</refname>
@ -73,15 +73,14 @@
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
/*
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
@ -91,37 +90,39 @@ printf("Host information: %s\n", $mysqli->host_info);
/* close connection */
$mysqli->close();
?>
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
</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");
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* check connection */
if (!$link) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
printf("Host information: %s\n", mysqli_get_host_info($link));
/* close connection */
mysqli_close($link);
?>
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1>
<title>See also</title>
</programlisting>
</example>
<para>
<function>mysqli_close</function>,
<function>mysqli_init</function>,
<function>mysqli_options</function>
<function>mysqli_real_connect</function>.
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Host information: Localhost via UNIX socket
]]>
</screen>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.11 $ -->
<!-- $Revision: 1.12 $ -->
<refentry id="function.mysqli-data-seek">
<refnamediv>
<refname>mysqli_data_seek</refname>
@ -52,74 +52,85 @@
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
/* Open a connection */
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
$mysqli->query( "DROP TABLE IF EXISTS friends");
$mysqli->query( "CREATE TABLE friends (id int, name varchar(30))");
$mysqli->query( "INSERT INTO friends VALUES (1, 'Greant'),
(2, 'Stocker'), (3, 'Rethans'), (4, 'Wendel')");
/* Get some rows */
$query = "SELECT name FROM friends ORDER BY name";
$result = $mysqli->query( $query) or die(mysqli_error($link));
$total = $result->field_count;
if ($total > 0) { // there is at least one row
/* Get the last employee */
$result->data_seek($result->num_rows -1);
$friend = $result->fetch_row();
printf ("Friends name : %s\n", $friend[0]);
/* 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 ($result = $mysqli->query( $query)) {
/* seek to row no. 400 */
$result->data_seek(399);
/* fetch row */
$row = $result->fetch_row();
printf ("City: %s Countrycode: %s\n", $row[0], $row[1]);
$result->close();
/* free result set*/
$result->close();
}
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Object oriented style</title>
<programlisting role="php">
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
/* Open a connection */
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
mysqli_query($link, "DROP TABLE IF EXISTS friends");
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(30))");
mysqli_query($link, "INSERT INTO friends VALUES (1, 'Greant'),
(2, 'Stocker'), (3, 'Rethans'), (4, 'Wendel')");
/* Get some rows */
$query = "SELECT name FROM friends ORDER BY name";
$result = mysqli_query($link, $query) or die(mysqli_error($link));
$total = mysqli_num_fields($result);
if ($total > 0) { /* there is at least one row */
/* Get the last employee */
mysqli_data_seek($result, mysqli_num_rows($result) -1);
$friend = mysqli_fetch_row($result);
printf ("Friends name : %s\n", $friend[0]);
/* check connection */
if (!$link) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT Name, CountryCode FROM City ORDER BY Name";
if ($result = mysqli_query($link, $query)) {
/* seek to row no. 400 */
mysqli_data_seek($result, 399);
/* fetch row */
$row = mysqli_fetch_row($result);
printf ("City: %s Countrycode: %s\n", $row[0], $row[1]);
mysqli_free_result($result);
/* free result set*/
mysqli_free_result($result);
}
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
City: Benin City Countrycode: NGA
]]>
</screen>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<refentry id="function.mysqli-errno">
<refnamediv>
<refname>mysqli_errno</refname>
@ -50,39 +50,61 @@
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$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 (!$mysqli->query("SET a=1")) {
printf("Errorcode: %d\n", $mysqli->errno);
}
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
$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 (!mysqli_query($link, "SET a=1")) {
printf("Errorcode: %d\n", mysqli_errno($link));
}
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
</refsect1>
<screen>
<![CDATA[
Errorcode: 1193
]]>
</screen>
</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.9 $ -->
<!-- $Revision: 1.10 $ -->
<refentry id="function.mysqli-error">
<refnamediv>
<refname>mysqli_error</refname>
@ -43,39 +43,61 @@
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$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 (!$mysqli->query("SET a=1")) {
printf("Errorcode: %d\n", $mysqli->error);
printf("Errormessage: %s\n", $mysqli->error);
}
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
$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 (!mysqli_query($link, "SET a=1")) {
printf("Errorcode: %s\n", mysqli_error($link));
printf("Errormessage: %s\n", mysqli_error($link));
}
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
</refsect1>
<screen>
<![CDATA[
Errormessage: Unknown system variable 'a'
]]>
</screen>
</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.9 $ -->
<!-- $Revision: 1.10 $ -->
<refentry id="function.mysqli-execute">
<refnamediv>
<refname>mysqli_execute</refname>
@ -53,94 +53,129 @@
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
$mysqli->query("DROP TABLE IF EXISTS friends");
$mysqli->query("CREATE TABLE friends (id int, name varchar(20))");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$mysqli->query("CREATE TABLE myCity LIKE City");
/* Prepare an insert statement */
$query = "INSERT INTO friends VALUES(?, ?)";
$query = "INSERT INTO myCity (Name, CountryCode, District) VALUES (?,?,?)";
$stmt = $mysqli->prepare($query);
$stmt->bind_param("is", $val1, $val2);
$stmt->bind_param("sss", $val1, $val2, $val3);
$val1 = 1;
$val2 = 'Miller';
$val1 = 'Stuttgart';
$val2 = 'DEU';
$val3 = 'Baden-Wuerttemberg';
/* Execute the statement */
$stmt->execute();
$val1 = 2;
$val2 = 'Wagner';
$val1 = 'Bordeaux';
$val2 = 'FRA';
$val3 = 'Aquitaine';
/* Execute the statement */
$stmt->execute();
/* close statement */
$stmt->close();
/* Return the affected rows for the statement */
if ($result = $mysqli->query("SELECT id,name FROM friends")) {
/* retrieve all rows from myCity */
$query = "SELECT Name, CountryCode, District FROM myCity";
if ($result = $mysqli->query($query)) {
while ($row = $result->fetch_row()) {
printf("ID: %s Name: %s\n", $row[0], $row[1]);
printf("%s (%s,%s)\n", $row[0], $row[1], $row[2]);
}
/* free result set */
$result->close();
}
/* remove table */
$mysqli->query("DROP TABLE myCity");
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
mysqli_query($link, "DROP TABLE IF EXISTS friends");
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
mysqli_query($link, "CREATE TABLE myCity LIKE City");
/* Prepare an insert statement */
$query = "INSERT INTO friends VALUES(?, ?)";
$query = "INSERT INTO myCity (Name, CountryCode, District) VALUES (?,?,?)";
$stmt = mysqli_prepare($link, $query);
mysqli_bind_param($stmt, "is", $val1, $val2);
mysqli_bind_param($stmt, "sss", $val1, $val2, $val3);
$val1 = 1;
$val2 = 'Miller';
/* Execute the statement */
mysqli_execute($stmt);
$val1 = 2;
$val2 = 'Wagner';
$val1 = 'Stuttgart';
$val2 = 'DEU';
$val3 = 'Baden-Wuerttemberg';
/* Execute the statement */
mysqli_execute($stmt);
$val1 = 'Bordeaux';
$val2 = 'FRA';
$val3 = 'Aquitaine';
/* Execute the statement */
mysqli_execute($stmt);
/* close statement */
mysqli_stmt_close($stmt);
/* Return the affected rows for the statement */
if ($result = mysqli_query($link, "SELECT id,name FROM friends")) {
/* retrieve all rows from myCity */
$query = "SELECT Name, CountryCode, District FROM myCity";
if ($result = mysqli_query($link, $query)) {
while ($row = mysqli_fetch_row($result)) {
printf("ID: %s Name: %s\n", $row[0], $row[1]);
printf("%s (%s,%s)\n", $row[0], $row[1], $row[2]);
}
/* free result set */
mysqli_free_result($result);
}
/* remove table */
mysqli_query($link, "DROP TABLE myCity");
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Stuttgart (DEU,Baden-Wuerttemberg)
Bordeaux (FRA,Aquitaine)
]]>
</screen>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.10 $ -->
<!-- $Revision: 1.11 $ -->
<refentry id="function.mysqli-fetch-array">
<refnamediv>
<refname>mysqli_fetch_array</refname>
@ -68,89 +68,90 @@
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
$mysqli->query("DROP TABLE IF EXISTS friends");
$mysqli->query("CREATE TABLE friends (id int, name varchar(20))");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$mysqli->query("INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
$result = $mysqli->query( "SELECT id, name FROM friends");
$query = "SELECT Name, CountryCode FROM City ORDER by ID LIMIT 3";
$result = $mysqli->query($query);
/* numeric array */
while ($row = $result->fetch_array(MYSQLI_NUM)) {
printf ("ID: %s Name: %s\n", $row[0], $row[1]);
}
$result->close();
$result = $mysqli->query("SELECT id, name FROM friends");
$row = $result->fetch_array(MYSQLI_NUM);
printf ("%s (%s)\n", $row[0], $row[1]);
/* associative array */
while ($row = $result->fetch_array(MYSQLI_ASSOC)) {
printf ("ID: %s Name: %s\n", $row["id"], $row["name"]);
}
$result->close();
$result = $mysqli->query("SELECT id, name FROM friends");
$row = $result->fetch_array(MYSQLI_ASSOC);
printf ("%s (%s)\n", $row["Name"], $row["CountryCode"]);
/* associative and numeric array */
while ($row = $result->fetch_array(MYSQLI_BOTH)) {
printf ("ID: %s Name: %s\n", $row[0], $row["name"]);
}
$row = $result->fetch_array(MYSQLI_BOTH);
printf ("%s (%s)\n", $row[0], $row["CountryCode"]);
/* free result set */
$result->close();
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
mysqli_query($link, "DROP TABLE IF EXISTS friends");
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$result = mysqli_query($link, "SELECT id, name FROM friends");
$query = "SELECT Name, CountryCode FROM City ORDER by ID LIMIT 3";
$result = mysqli_query($link, $query);
/* numeric array */
while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) {
printf ("ID: %s Name: %s\n", $row[0], $row[1]);
}
mysqli_free_result($result);
$result = mysqli_query($link, "SELECT id, name FROM friends");
$row = mysqli_fetch_array($result, MYSQLI_NUM);
printf ("%s (%s)\n", $row[0], $row[1]);
/* associative array */
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
printf ("ID: %s Name: %s\n", $row["id"], $row["name"]);
}
mysqli_free_result($result);
$result = mysqli_query($link, "SELECT id, name FROM friends");
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
printf ("%s (%s)\n", $row["Name"], $row["CountryCode"]);
/* associative and numeric array */
while ($row = mysqli_fetch_array($result, MYSQLI_BOTH)) {
printf ("ID: %s Name: %s\n", $row[0], $row["name"]);
}
$row = mysqli_fetch_array($result, MYSQLI_BOTH);
printf ("%s (%s)\n", $row[0], $row["CountryCode"]);
/* free result set */
mysqli_free_result($result);
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Kabul (AFG)
Qandahar (AFG)
Herat (AFG)
]]>
</screen>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.8 $ -->
<!-- $Revision: 1.9 $ -->
<refentry id="function.mysqli-fetch-assoc">
<refnamediv>
<refname>mysqli_fetch_assoc</refname>
@ -62,49 +62,77 @@
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
$mysqli->query( "DROP TABLE IF EXISTS friends");
$mysqli->query( "CREATE TABLE friends (id int, name varchar(20))");
$mysqli->query( "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
$result = $mysqli->query( "SELECT id, name FROM friends");
while ($row = $result->fetch_assoc()) {
printf ("ID: %s Name: %s\n", $row["id"], $row["name"]);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$result->close();
$query = "SELECT Name, CountryCode FROM City ORDER by ID DESC LIMIT 50,5";
if ($result = $mysqli->query($query)) {
/* fetch associative array */
while ($row = $result->fetch_assoc()) {
printf ("%s (%s)\n", $row["Name"], $row["CountryCode"]);
}
/* free result set */
$result->close();
}
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
mysqli_query($link, "DROP TABLE IF EXISTS friends");
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$result = mysqli_query($link, "SELECT id, name FROM friends");
$query = "SELECT Name, CountryCode FROM City ORDER by ID DESC LIMIT 50,5";
while ($row = mysqli_fetch_assoc($result)) {
printf ("ID: %s Name: %s\n", $row["id"], $row["name"]);
if ($result = mysqli_query($link, $query)) {
/* fetch associative array */
while ($row = mysqli_fetch_assoc($result)) {
printf ("%s (%s)\n", $row["Name"], $row["CountryCode"]);
}
mysqli_free_result($result);
/* free 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[
Pueblo (USA)
Arvada (USA)
Cape Coral (USA)
Green Bay (USA)
Santa Clara (USA)
]]>
</screen>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<refentry id="function.mysqli-fetch-field-direct">
<refnamediv>
<refname>mysqli_fetch_field_direct</refname>
@ -104,63 +104,83 @@
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
$mysqli->query( "DROP TABLE IF EXISTS friends");
$mysqli->query( "CREATE TABLE friends (id int, name varchar(20))");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT Name, SurfaceArea from Country ORDER BY Name LIMIT 5";
if ($result = $mysqli->query($query)) {
/* Get field information for column 'SurfaceArea' */
$finfo = $result->fetch_field_direct(1);
$mysqli->query( "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
$result = $mysqli->query( "SELECT id, name FROM friends");
/* Get field information for column 'name' */
$finfo = $result->fetch_field_direct(1);
printf("Name: %s\n", $finfo->name);
printf("Table: %s\n", $finfo->table);
printf("Default: %s\n", $finfo->def);
printf("max. Len: %d\n", $finfo->max_length);
printf("Flags: %d\n", $finfo->flags);
printf("Type: %d\n", $finfo->type);
printf("Name: %s\n", $finfo->name);
printf("Table: %s\n", $finfo->table);
printf("max. Len: %d\n", $finfo->max_length);
printf("Flags: %d\n", $finfo->flags);
printf("Type: %d\n", $finfo->type);
$result->close();
$result->close();
}
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
mysqli_query($link, "DROP TABLE IF EXISTS friends");
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT Name, SurfaceArea from Country ORDER BY Name LIMIT 5";
if ($result = mysqli_query($link, $query)) {
/* Get field information for column 'SurfaceArea' */
$finfo = mysqli_fetch_field_direct($result, 1);
mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
printf("Name: %s\n", $finfo->name);
printf("Table: %s\n", $finfo->table);
printf("max. Len: %d\n", $finfo->max_length);
printf("Flags: %d\n", $finfo->flags);
printf("Type: %d\n", $finfo->type);
$result = mysqli_query($link, "SELECT id, name FROM friends");
/* Get field information for column 'name' */
$finfo = mysqli_fetch_field_direct($result, 1);
printf("Name: %s\n", $finfo->name);
printf("Table: %s\n", $finfo->table);
printf("Default: %s\n", $finfo->def);
printf("max. Len: %d\n", $finfo->max_length);
printf("Flags: %d\n", $finfo->flags);
printf("Type: %d\n", $finfo->type);
mysqli_free_result($result);
mysqli_free_result($result);
}
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Name: SurfaceArea
Table: Country
max. Len: 10
Flags: 32769
Type: 4
]]>
</screen>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<refentry id="function.mysqli-fetch-field">
<refnamediv>
<refname>mysqli_fetch_field</refname>
@ -99,70 +99,95 @@
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role='php'>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
$mysqli->query( "DROP TABLE IF EXISTS friends");
$mysqli->query( "CREATE TABLE friends (id int, name varchar(20))");
$mysqli->query( "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
$result = $mysqli->query( "SELECT id, name FROM friends");
/* Get field information for all columns */
while ($finfo = $result->fetch_field()) {
printf("Name: %s\n", $finfo->name);
printf("Table: %s\n", $finfo->table);
printf("Default: %s\n", $finfo->def);
printf("max. Len: %d\n", $finfo->max_length);
printf("Flags: %d\n", $finfo->flags);
printf("Type: %d\n", $finfo->type);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$result->close();
$query = "SELECT Name, SurfaceArea from Country ORDER BY Code LIMIT 5";
if ($result = $mysqli->query($query)) {
/* Get field information for all columns */
while ($finfo = $result->fetch_field()) {
printf("Name: %s\n", $finfo->name);
printf("Table: %s\n", $finfo->table);
printf("max. Len: %d\n", $finfo->max_length);
printf("Flags: %d\n", $finfo->flags);
printf("Type: %d\n\n", $finfo->type);
}
$result->close();
}
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role='php'>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
mysqli_query($link, "DROP TABLE IF EXISTS friends");
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
$result = mysqli_query($link, "SELECT id, name FROM friends");
/* Get field information for all columns */
while ($finfo = mysqli_fetch_field($result)) {
printf("Name: %s\n", $finfo->name);
printf("Table: %s\n", $finfo->table);
printf("Default: %s\n", $finfo->def);
printf("max. Len: %d\n", $finfo->max_length);
printf("Flags: %d\n", $finfo->flags);
printf("Type: %d\n", $finfo->type);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
mysqli_free_result($result);
$query = "SELECT Name, SurfaceArea from Country ORDER BY Code LIMIT 5";
if ($result = mysqli_query($link, $query)) {
/* Get field information for all fields */
while ($finfo = mysqli_fetch_field($result)) {
printf("Name: %s\n", $finfo->name);
printf("Table: %s\n", $finfo->table);
printf("max. Len: %d\n", $finfo->max_length);
printf("Flags: %d\n", $finfo->flags);
printf("Type: %d\n\n", $finfo->type);
}
mysqli_free_result($result);
}
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Name: Name
Table: Country
max. Len: 11
Flags: 1
Type: 254
Name: SurfaceArea
Table: Country
max. Len: 10
Flags: 32769
Type: 4
]]>
</screen>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<refentry id="function.mysqli-fetch-fields">
<refnamediv>
<refname>mysqli_fetch_fields</refname>
@ -98,74 +98,97 @@
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role='php'>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
mysqli_query($link, "DROP TABLE IF EXISTS friends");
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
$result = mysqli_query($link, "SELECT id, name FROM friends");
/* Get field informations */
$finfo = mysqli_fetch_fields($result);
for ($i=0; $i < count($finfo); $i++) {
printf("Name: %s\n", $finfo[$i]->name);
printf("Table: %s\n", $finfo[$i]->table);
printf("Default: %s\n", $finfo[$i]->def);
printf("max. Len: %d\n", $finfo[$i]->max_length);
printf("Flags: %d\n", $finfo[$i]->flags);
printf("Type: %d\n", $finfo[$i]->type);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
mysqli_free_result($result);
$query = "SELECT Name, SurfaceArea from Country ORDER BY Code LIMIT 5";
mysqli_close($link);
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role='php'>
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
if ($result = $mysqli->query($query)) {
$mysqli->query( "DROP TABLE IF EXISTS friends");
$mysqli->query( "CREATE TABLE friends (id int, name varchar(20))");
$mysqli->query( "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
/* Get field information for all columns */
$finfo = $result->fetch_fields();
$result = $mysqli->query( "SELECT id, name FROM friends");
/* Get field information for column 'name' */
$finfo = $result->fetch_fields();
for ($i=0; $i < count($finfo); $i++) {
printf("Name: %s\n", $finfo[$i]->name);
printf("Table: %s\n", $finfo[$i]->table);
printf("Default: %s\n", $finfo[$i]->def);
printf("max. Len: %d\n", $finfo[$i]->max_length);
printf("Flags: %d\n", $finfo[$i]->flags);
printf("Type: %d\n", $finfo[$i]->type);
for ($i=0; $i < count($finfo); $i++) {
printf("Name: %s\n", $finfo[$i]->name);
printf("Table: %s\n", $finfo[$i]->table);
printf("max. Len: %d\n", $finfo[$i]->max_length);
printf("Flags: %d\n", $finfo[$i]->flags);
printf("Type: %d\n\n", $finfo[$i]->type);
}
$result->close();
}
$result->close();
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
</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 Name, SurfaceArea from Country ORDER BY Code LIMIT 5";
if ($result = mysqli_query($link, $query)) {
/* Get field information for all columns */
$finfo = mysqli_fetch_fields($result);
for ($i=0; $i < count($finfo); $i++) {
printf("Name: %s\n", $finfo[$i]->name);
printf("Table: %s\n", $finfo[$i]->table);
printf("max. Len: %d\n", $finfo[$i]->max_length);
printf("Flags: %d\n", $finfo[$i]->flags);
printf("Type: %d\n\n", $finfo[$i]->type);
}
mysqli_free_result($result);
}
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Name: Name
Table: Country
max. Len: 11
Flags: 1
Type: 254
Name: SurfaceArea
Table: Country
max. Len: 10
Flags: 32769
Type: 4
]]>
</screen>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.8 $ -->
<!-- $Revision: 1.9 $ -->
<refentry id="function.mysqli-fetch-lengths">
<refnamediv>
<refname>mysqli_fetch_lengths</refname>
@ -39,66 +39,93 @@
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role='php'>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
$mysqli->query( "DROP TABLE IF EXISTS friends");
$mysqli->query( "CREATE TABLE friends (id int, name varchar(20))");
$mysqli->query( "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
$result = $mysqli->query( "SELECT id, name FROM friends");
$row = $result->fetch_row();
/* Print field lengths */
for ($i=0; $i < count($result->lengths); $i++) {
printf("Field %d has length %d\n", $i, $result->lengths[$i]);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$result->close();
$query = "SELECT * from Country ORDER BY Code LIMIT 1";
if ($result = $mysqli->query($query)) {
$row = $result->fetch_row();
/* display column lengths */
for ($i=0; $i < count($result->lengths); $i++) {
printf("Field %2d has Length %2d\n", $i+1, $result->lengths[$i]);
}
$result->close();
}
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role='php'>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
mysqli_query($link, "DROP TABLE IF EXISTS friends");
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
$result = mysqli_query($link, "SELECT id, name FROM friends");
$row = mysqli_fetch_row($result);
/* Get field lengths */
$lengths = mysqli_fetch_lengths($result);
for ($i=0; $i < count($lengths); $i++) {
printf("Field %d has length %d\n", $i, $lengths[$i]);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
mysqli_free_result($result);
$query = "SELECT * from Country ORDER BY Code LIMIT 1";
if ($result = mysqli_query($link, $query)) {
$row = mysqli_fetch_row($result);
/* display column lengths */
$lengths = mysqli_fetch_lengths($result);
for ($i=0; $i < count($lengths); $i++) {
printf("Field %2d has Length %2d\n", $i+1, $lengths[$i]);
}
mysqli_free_result($result);
}
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Field 1 has Length 3
Field 2 has Length 5
Field 3 has Length 13
Field 4 has Length 9
Field 5 has Length 6
Field 6 has Length 1
Field 7 has Length 6
Field 8 has Length 4
Field 9 has Length 6
Field 10 has Length 6
Field 11 has Length 5
Field 12 has Length 44
Field 13 has Length 7
Field 14 has Length 3
Field 15 has Length 2
]]>
</screen>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.8 $ -->
<!-- $Revision: 1.9 $ -->
<refentry id="function.mysqli-fetch-object">
<refnamediv>
<refname>mysqli_fetch_object</refname>
@ -45,58 +45,82 @@
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role='php'>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
mysqli_query($link, "DROP TABLE IF EXISTS friends");
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
$query = "SELECT Name, CountryCode FROM City ORDER by ID DESC LIMIT 50,5";
$result = mysqli_query($link, "SELECT id, name FROM friends");
if ($result = $mysqli->query($query)) {
/* fetch object */
$obj = mysqli_fetch_object($result);
/* fetch object array */
while ($obj = $result->fetch_object()) {
printf ("%s (%s)\n", $obj->Name, $obj->CountryCode);
}
printf("Id: %d Name: %s\n", $obj->id, $obj->name);
/* free result set */
$result->close();
}
mysqli_free_result($result);
mysqli_close($link);
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role='php'>
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$mysqli->query( "DROP TABLE IF EXISTS friends");
$mysqli->query( "CREATE TABLE friends (id int, name varchar(20))");
$mysqli->query( "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
$result = $mysqli->query( "SELECT id, name FROM friends");
/* fetch object */
$obj = $result->fetch_object();
printf("Id: %d Name: %s\n", $obj->id, $obj->name);
$result->close();
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
</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 Name, CountryCode FROM City ORDER by ID DESC LIMIT 50,5";
if ($result = mysqli_query($link, $query)) {
/* fetch associative array */
while ($obj = mysqli_fetch_object($result)) {
printf ("%s (%s)\n", $obj->Name, $obj->CountryCode);
}
/* free 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[
Pueblo (USA)
Arvada (USA)
Cape Coral (USA)
Green Bay (USA)
Santa Clara (USA)
]]>
</screen>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<refentry id="function.mysqli-fetch-row">
<refnamediv>
<refname>mysqli_fetch_row</refname>
@ -50,58 +50,82 @@
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role='php'>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
$mysqli->query( "DROP TABLE IF EXISTS friends");
$mysqli->query( "CREATE TABLE friends (id int, name varchar(20))");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$mysqli->query( "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
$query = "SELECT Name, CountryCode FROM City ORDER by ID DESC LIMIT 50,5";
$result = $mysqli->query( "SELECT id, name FROM friends");
if ($result = $mysqli->query($query)) {
/* fetch object */
$row = $result->fetch_row();
/* fetch object array */
while ($row = $result->fetch_row()) {
printf ("%s (%s)\n", $row[0], $row[1]);
}
printf("Id: %d Name: %s\n", $row[0], $row[1]);
/* free result set */
$result->close();
}
$result->close();
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role='php'>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
mysqli_query($link, "DROP TABLE IF EXISTS friends");
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$result = mysqli_query($link, "SELECT id, name FROM friends");
$query = "SELECT Name, CountryCode FROM City ORDER by ID DESC LIMIT 50,5";
/* fetch object */
$row = mysqli_fetch_row($result);
if ($result = mysqli_query($link, $query)) {
printf("Id: %d Name: %s\n", $row[0], $row[1]);
/* fetch associative array */
while ($row = mysqli_fetch_row($result)) {
printf ("%s (%s)\n", $row[0], $row[1]);
}
mysqli_free_result($result);
/* free result set */
mysqli_free_result($result);
}
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Pueblo (USA)
Arvada (USA)
Cape Coral (USA)
Green Bay (USA)
Santa Clara (USA)
]]>
</screen>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<refentry id="function.mysqli-fetch">
<refnamediv>
<refname>mysqli_fetch</refname>
@ -72,70 +72,94 @@
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role='php'>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
$mysqli->query( "DROP TABLE IF EXISTS friends");
$mysqli->query( "CREATE TABLE friends (id int, name varchar(20))");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$mysqli->query( "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
$query = "SELECT Name, CountryCode FROM City ORDER by ID DESC LIMIT 150,5";
$stmt = $mysqli->prepare( "SELECT id, name FROM friends");
if ($stmt = $mysqli->prepare($query)) {
/* execute statement */
$stmt->execute();
/* execute statement */
$stmt->execute();
/* bind result variables */
$stmt->bind_result($column1, $column2);
/* bind result variables */
$stmt->bind_result($name, $code);
/* fetch result */
while ($stmt->fetch()) {
printf("Id: %d Name: %s\n", $column1, $column2);
/* fetch values */
while ($stmt->fetch()) {
printf ("%s (%s)\n", $name, $code);
}
/* close statement */
$stmt->close();
}
$stmt->close();
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role='php'>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
mysqli_query($link, "DROP TABLE IF EXISTS friends");
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
$stmt = mysqli_prepare($link, "SELECT id, name FROM friends");
/* execute statement */
mysqli_execute($stmt);
/* bind result variables */
mysqli_bind_result($stmt, $column1, $column2);
/* fetch result */
while (mysqli_fetch($stmt)) {
printf("Id: %d Name: %s\n", $column1, $column2);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
mysqli_stmt_close($stmt);
$query = "SELECT Name, CountryCode FROM City ORDER by ID DESC LIMIT 150,5";
if ($stmt = mysqli_prepare($link, $query)) {
/* execute statement */
mysqli_execute($stmt);
/* bind result variables */
mysqli_bind_result($stmt, $name, $code);
/* fetch values */
while (mysqli_fetch($stmt)) {
printf ("%s (%s)\n", $name, $code);
}
/* close statement */
mysqli_stmt_close($stmt);
}
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Rockford (USA)
Tallahassee (USA)
Salinas (USA)
Santa Clarita (USA)
Springfield (USA)
]]>
</screen>
</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-field-seek">
<refnamediv>
<refname>mysqli_field_seek</refname>
@ -47,75 +47,91 @@
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role='php'>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
$mysqli->query( "DROP TABLE IF EXISTS friends");
$mysqli->query( "CREATE TABLE friends (id int, name varchar(20))");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT Name, SurfaceArea from Country ORDER BY Code LIMIT 5";
if ($result = $mysqli->query($query)) {
/* Get field information for 2nd column */
$result->field_seek(1);
$finfo = $result->fetch_field();
$mysqli->query( "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
$result = $mysqli->query( "SELECT id, name FROM friends");
/* set field pointer to column name */
$result->field_seek(1);
/* fetch field information */
$finfo = $result->fetch_field();
printf("Name: %s\n", $finfo->name);
printf("Table: %s\n", $finfo->table);
printf("Default: %s\n", $finfo->def);
printf("max. Len: %d\n", $finfo->max_length);
printf("Flags: %d\n", $finfo->flags);
printf("Type: %d\n", $finfo->type);
$result->close();
printf("Name: %s\n", $finfo->name);
printf("Table: %s\n", $finfo->table);
printf("max. Len: %d\n", $finfo->max_length);
printf("Flags: %d\n", $finfo->flags);
printf("Type: %d\n\n", $finfo->type);
$result->close();
}
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role='php'>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
mysqli_query($link, "DROP TABLE IF EXISTS friends");
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT Name, SurfaceArea from Country ORDER BY Code LIMIT 5";
if ($result = mysqli_query($link, $query)) {
/* Get field information for 2nd column */
mysqli_field_seek($result, 1);
$finfo = mysqli_fetch_field($result);
mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
printf("Name: %s\n", $finfo->name);
printf("Table: %s\n", $finfo->table);
printf("max. Len: %d\n", $finfo->max_length);
printf("Flags: %d\n", $finfo->flags);
printf("Type: %d\n\n", $finfo->type);
$result = mysqli_query($link, "SELECT id, name FROM friends");
/* set field pointer to column name */
mysqli_field_seek($result, 1);
/* fetch field information */
$finfo = mysqli_fetch_field($result);
printf("Name: %s\n", $finfo->name);
printf("Table: %s\n", $finfo->table);
printf("Default: %s\n", $finfo->def);
printf("max. Len: %d\n", $finfo->max_length);
printf("Flags: %d\n", $finfo->flags);
printf("Type: %d\n", $finfo->type);
mysqli_free_result($result);
mysqli_free_result($result);
}
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Name: SurfaceArea
Table: Country
max. Len: 10
Flags: 32769
Type: 4
]]>
</screen>
</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-field-tell">
<refnamediv>
<refname>mysqli_field_tell</refname>
@ -44,75 +44,105 @@
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role='php'>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
$mysqli->query( "DROP TABLE IF EXISTS friends");
$mysqli->query( "CREATE TABLE friends (id int, name varchar(20))");
$mysqli->query( "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
$result = $mysqli->query( "SELECT id, name FROM friends");
while ($finfo = mysqli_fetch_field($result)) {
/* get field pointer position */
$fieldnr = mysqli_field_tell($result);
printf("Fieldnr: %d\n", $fieldnr);
printf("Name: %s\n", $finfo->name);
printf("Table: %s\n", $finfo->table);
printf("Default: %s\n", $finfo->def);
printf("max. Len: %d\n", $finfo->max_length);
printf("Flags: %d\n", $finfo->flags);
printf("Type: %d\n", $finfo->type);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$result->close();
$query = "SELECT Name, SurfaceArea from Country ORDER BY Code LIMIT 5";
if ($result = $mysqli->query($query)) {
/* Get field information for all columns */
while ($finfo = $result->fetch_field()) {
/* get fieldpointer offset */
$currentfield = $result->current_field;
printf("Column %d:\n", $currentfield);
printf("Name: %s\n", $finfo->name);
printf("Table: %s\n", $finfo->table);
printf("max. Len: %d\n", $finfo->max_length);
printf("Flags: %d\n", $finfo->flags);
printf("Type: %d\n\n", $finfo->type);
}
$result->close();
}
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role='php'>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
mysqli_query($link, "DROP TABLE IF EXISTS friends");
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
$result = mysqli_query($link, "SELECT id, name FROM friends");
while ($finfo = $result->fetch_field()) {
/* get field pointer position */
$fieldnr = $result->current_field;
printf("Fieldnr: %d\n", $fieldnr);
printf("Name: %s\n", $finfo->name);
printf("Table: %s\n", $finfo->table);
printf("Default: %s\n", $finfo->def);
printf("max. Len: %d\n", $finfo->max_length);
printf("Flags: %d\n", $finfo->flags);
printf("Type: %d\n", $finfo->type);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
mysqli_free_result($result);
$query = "SELECT Name, SurfaceArea from Country ORDER BY Code LIMIT 5";
if ($result = mysqli_query($link, $query)) {
/* Get field information for all fields */
while ($finfo = mysqli_fetch_field($result)) {
/* get fieldpointer offset */
$currentfield = mysqli_field_tell($result);
printf("Column %d:\n", $currentfield);
printf("Name: %s\n", $finfo->name);
printf("Table: %s\n", $finfo->table);
printf("max. Len: %d\n", $finfo->max_length);
printf("Flags: %d\n", $finfo->flags);
printf("Type: %d\n\n", $finfo->type);
}
mysqli_free_result($result);
}
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Column 1:
Name: Name
Table: Country
max. Len: 11
Flags: 1
Type: 254
Column 2:
Name: SurfaceArea
Table: Country
max. Len: 10
Flags: 32769
Type: 4
]]>
</screen>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<refentry id="function.mysqli-get-host-info">
<refnamediv>
<refname>mysqli_get_host_info</refname>
@ -38,13 +38,18 @@
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role='php'>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password");
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* print host information */
printf("Host info: %s\n", $mysqli->host_info);
@ -53,14 +58,20 @@ printf("Host info: %s\n", $mysqli->host_info);
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role='php'>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password");
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* print host information */
printf("Host info: %s\n", mysqli_get_host_info($link));
@ -69,9 +80,16 @@ printf("Host info: %s\n", mysqli_get_host_info($link));
mysqli_close($link);
?>
]]>
</programlisting>
</example>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Host info: Localhost via UNIX socket
]]>
</screen>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<refentry id="function.mysqli-get-proto-info">
<refnamediv>
<refname>mysqli_get_proto_info</refname>
@ -37,40 +37,58 @@
</refsect1>
<refsect1>
<title>Example</title>
<para>
<example>
<title>Object oriented style</title>
<programlisting role='php'>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password");
/* print host information */
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* print protocol version */
printf("Protocol version: %d\n", $mysqli->protocol_version);
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role='php'>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password");
/* print host information */
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* print protocol version */
printf("Protocol version: %d\n", mysqli_get_proto_info($link));
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Protocol version: 10
]]>
</screen>
</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-get-server-info">
<refnamediv>
<refname>mysqli_get_server_info</refname>
@ -31,11 +31,68 @@
</para>
</refsect1>
<refsect1>
&reftitle.seealso;
<title>See also</title>
<para>
<function>mysqli_get_client_info</function>,
<function>mysqli_get_client_version</function>,
<function>mysqli_get_server_version</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");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* print server version */
printf("Server version: %s\n", $mysqli->server_info);
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* print server version */
printf("Server version: %s\n", mysqli_get_server_info($link));
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Server version: 4.1.2-alpha-debug
]]>
</screen>
</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.4 $ -->
<!-- $Revision: 1.5 $ -->
<refentry id="function.mysqli-get-server-version">
<refnamediv>
<refname>mysqli_get_server_version</refname>
@ -35,11 +35,68 @@
</para>
</refsect1>
<refsect1>
&reftitle.seealso;
<title>See also</title>
<para>
<function>mysqli_get_client_info</function>,
<function>mysqli_get_client_version</function>,
<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");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* print server version */
printf("Server version: %d\n", $mysqli->server_version);
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* print server version */
printf("Server version: %d\n", mysqli_get_server_version($link));
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Server version: 40102
]]>
</screen>
</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.4 $ -->
<!-- $Revision: 1.5 $ -->
<refentry id="function.mysqli-info">
<refnamediv>
<refname>mysqli_info</refname>
@ -79,6 +79,89 @@
<function>mysqli_num_rows</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 TEMPORARY TABLE t1 LIKE City");
/* INSERT INTO .. SELECT */
$mysqli->query("INSERT INTO t1 SELECT * FROM City ORDER BY ID LIMIT 150");
printf("%s\n", $mysqli->info);
/* 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 TEMPORARY TABLE t1 LIKE City");
/* INSERT INTO .. SELECT */
mysqli_query($link, "INSERT INTO t1 SELECT * FROM City ORDER BY ID LIMIT 150");
printf("%s\n", mysqli_info($link));
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Records: 150 Duplicates: 0 Warnings: 0
]]>
</screen>
</refsect1>
</refentry>
<!-- 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
-->
</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.4 $ -->
<!-- $Revision: 1.5 $ -->
<refentry id="function.mysqli-insert-id">
<refnamediv>
<refname>mysqli_insert_id</refname>
@ -48,7 +48,76 @@
</para>
</note>
</refsect1>
</refentry>
<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");
$query = "INSERT INTO myCity VALUES (NULL, 'Stuttgart', 'DEU', 'Stuttgart', 617000)";
$mysqli->query($query);
printf ("New Record has id %d.\n", $mysqli->insert_id);
/* drop table */
$mysqli->query("DROP TABLE myCity");
/* 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");
$query = "INSERT INTO myCity VALUES (NULL, 'Stuttgart', 'DEU', 'Stuttgart', 617000)";
mysqli_query($link, $query);
printf ("New Record has id %d.\n", mysqli_insert_id($link));
/* drop table */
mysqli_query($link, "DROP TABLE myCity");
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
New Record has id 1.
]]>
</screen>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:

View file

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='iso-8859-1'?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<reference id='ref.mysqli'>
<title>Improved MySQL Extension</title>
<titleabbrev>mysqli</titleabbrev>
@ -300,6 +300,9 @@
<listitem>
<para><link linkend='function.mysqli-field-count'>field_count</link> - returns number of fields in resultset</para>
</listitem>
<listitem>
<para><link linkend='function.mysqli-fetch-lenghts'>lengths</link> - returns an an array of columnlengths</para>
</listitem>
<listitem>
<para><link linkend='function.mysqli-num-rows'>num_rows</link> - returns number of rows in resultset</para>
</listitem>
@ -309,7 +312,14 @@
</section>
&reference.mysqli.constants;
<section>
<title>Examples</title>
<para>
All Examples in the MySQLI documentation use the world database from MySQL AB.
The world database can be found at <ulink url="&url.mysql.example;">&url.mysql.example;</ulink>
</para>
</section>
</partintro>
&reference.mysqli.functions;