mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Added an example that replaces use of this deprecated function.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@181587 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
b09bba42b7
commit
9d7dd8cc1f
4 changed files with 71 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.10 $ -->
|
||||
<!-- $Revision: 1.11 $ -->
|
||||
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.mysql-create-db">
|
||||
<refnamediv>
|
||||
|
@ -25,7 +25,7 @@
|
|||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>MySQL create database example</title>
|
||||
<title><function>mysql_create_db</function> alternative example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
@ -34,8 +34,9 @@ if (!$link) {
|
|||
die('Could not connect: ' . mysql_error());
|
||||
}
|
||||
|
||||
if (mysql_create_db('my_db')) {
|
||||
echo "Database created successfully\n";
|
||||
$sql = 'CREATE DATABASE my_db';
|
||||
if (mysql_query($sql, $link)) {
|
||||
echo "Database my_db created successfully\n";
|
||||
} else {
|
||||
echo 'Error creating database: ' . mysql_error() . "\n";
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.mysql-db-query">
|
||||
<refnamediv>
|
||||
|
@ -39,6 +39,43 @@
|
|||
<literal>database.table</literal> syntax in their sql queries instead of
|
||||
this function.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>mysql_db_query</function> alternative example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$dbname = 'mysql_dbname';
|
||||
|
||||
if (!$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) {
|
||||
echo 'Could not connect to mysql';
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!mysql_select_db($dbname, $link)) {
|
||||
echo 'Could not select database';
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = 'SELECT foo FROM bar WHERE id = 42';
|
||||
$result = mysql_query($sql, $link);
|
||||
|
||||
if (!$result) {
|
||||
echo "DB Error, could not list tables\n";
|
||||
echo 'MySQL Error: ' . mysql_error();
|
||||
exit;
|
||||
}
|
||||
|
||||
while ($row = mysql_fetch_assoc($result)) {
|
||||
echo $row['foo'];
|
||||
}
|
||||
|
||||
mysql_free_result($result);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
See also <function>mysql_connect</function> and
|
||||
<function>mysql_query</function>.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.10 $ -->
|
||||
<!-- $Revision: 1.11 $ -->
|
||||
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.mysql-drop-db">
|
||||
<refnamediv>
|
||||
|
@ -34,6 +34,28 @@
|
|||
<literal>SQL DROP DATABASE</literal> statement instead.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>mysql_drop_db</function> alternative example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
|
||||
if (!$link) {
|
||||
die('Could not connect: ' . mysql_error());
|
||||
}
|
||||
|
||||
$sql = 'DROP DATABASE my_db';
|
||||
if (mysql_query($sql, $link)) {
|
||||
echo "Database my_db was successfully dropped\n";
|
||||
} else {
|
||||
echo 'Error creating database: ' . mysql_error() . "\n";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<warning>
|
||||
<para>
|
||||
This function will not be available
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.12 $ -->
|
||||
<!-- $Revision: 1.13 $ -->
|
||||
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.mysql-list-tables">
|
||||
<refnamediv>
|
||||
|
@ -42,7 +42,7 @@
|
|||
</note>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>mysql_list_tables</function> example</title>
|
||||
<title><function>mysql_list_tables</function> alternative example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
@ -53,7 +53,8 @@ if (!mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) {
|
|||
exit;
|
||||
}
|
||||
|
||||
$result = mysql_list_tables($dbname);
|
||||
$sql = "SELECT TABLES FROM $dbname";
|
||||
$result = mysql_query($sql);
|
||||
|
||||
if (!$result) {
|
||||
echo "DB Error, could not list tables\n";
|
||||
|
@ -62,7 +63,7 @@ if (!$result) {
|
|||
}
|
||||
|
||||
while ($row = mysql_fetch_row($result)) {
|
||||
echo "Table: $row[0]\n";
|
||||
echo "Table: {$row[0]}\n";
|
||||
}
|
||||
|
||||
mysql_free_result($result);
|
||||
|
|
Loading…
Reference in a new issue