2002-04-15 00:12:54 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2004-02-20 17:36:42 +00:00
|
|
|
<!-- $Revision: 1.7 $ -->
|
2002-04-15 00:12:54 +00:00
|
|
|
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
|
|
|
|
<refentry id="function.mysql-select-db">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>mysql_select_db</refname>
|
|
|
|
<refpurpose>Select a MySQL database</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<methodsynopsis>
|
|
|
|
<type>bool</type><methodname>mysql_select_db</methodname>
|
|
|
|
<methodparam><type>string</type><parameter>database_name</parameter></methodparam>
|
|
|
|
<methodparam choice="opt"><type>resource</type><parameter>
|
|
|
|
link_identifier
|
|
|
|
</parameter></methodparam>
|
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
|
|
|
&return.success;
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<function>mysql_select_db</function> sets the current active
|
|
|
|
database on the server that's associated with the specified link
|
|
|
|
identifier. If no link identifier is specified, the last opened
|
|
|
|
link is assumed. If no link is open, the function will try to
|
|
|
|
establish a link as if <function>mysql_connect</function> was
|
|
|
|
called without arguments, and use it.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Every subsequent call to <function>mysql_query</function> will be
|
|
|
|
made on the active database.
|
|
|
|
</para>
|
2003-08-16 09:37:55 +00:00
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title><function>mysql_select_db</function> example</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
|
2004-02-20 17:36:42 +00:00
|
|
|
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
|
|
|
|
if (!$link) {
|
|
|
|
die('Not connected : ' . mysql_error());
|
|
|
|
}
|
2003-08-16 09:37:55 +00:00
|
|
|
|
|
|
|
// make foo the current db
|
2004-02-20 17:36:42 +00:00
|
|
|
$db_selected = mysql_select_db('foo', $link);
|
|
|
|
if (!$db_selected) {
|
|
|
|
die ('Can\'t use foo : ' . mysql_error());
|
|
|
|
}
|
2003-08-16 09:37:55 +00:00
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
2003-07-09 15:07:29 +00:00
|
|
|
<para>
|
|
|
|
See also
|
2002-04-15 00:12:54 +00:00
|
|
|
<function>mysql_connect</function>,
|
2003-07-09 15:07:29 +00:00
|
|
|
<function>mysql_pconnect</function> and
|
2002-04-15 00:12:54 +00:00
|
|
|
<function>mysql_query</function>.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
For downward compatibility <function>mysql_selectdb</function>
|
|
|
|
can also be used. This is deprecated however.
|
|
|
|
</para>
|
|
|
|
</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
|
|
|
|
-->
|