<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
  <refentry id="function.mysqli-change-user">
   <refnamediv>
    <refname>mysqli_change_user</refname>
    <refpurpose>Changes the user of the specified database connection</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>bool</type><methodname>mysqli_change_user</methodname>
      <methodparam><type>resource</type><parameter>link</parameter></methodparam>
      <methodparam><type>string</type><parameter>user</parameter></methodparam>
      <methodparam><type>string</type><parameter>password</parameter></methodparam>
      <methodparam><type>string</type><parameter>database</parameter></methodparam>
     </methodsynopsis>
    <para>
     <function>mysqli_change_user</function> is used to change the user of the specified
     database connection as given by the <parameter>link</parameter> parameter and to set the 
     current database to that specified by the <parameter>database</parameter> parameter. 
    </para>
    <para>
     &return.success;
    </para>
    <para>
     If desired, the &null; value may be passed in place of the <parameter>database</parameter>
     parameter resulting in only changing the user and not selecting a database. To select
     a database in this case use the <function>mysqli_select_db</function> function.
    </para>
    <para>
     In order to successfully change users a valid <parameter>username</parameter> and
     <parameter>password</parameter> parameters must be provided and that user must have
     sufficient permissions to access the desired database. If for any reason authorization
     fails, the current user authentication will remain.
    </para>
    <note>
     <para>
      Using this command will always cause the current database connection to behave as if
      was a completely new database connection, regardless of if the operation was completed
      successfully. This reset includes performing a rollback on any active transactions, 
      closing all temporary tables, and unlocking all locked tables.
     </para>
    </note>
    <para>
     <example>
      <title>Using the mysqli_change_user function</title>
      <programlisting role="php">
<![CDATA[
<?php
                            
    /* Open a connection as foo@localhost and select foo_db */
    $link = mysqli_connect("localhost", "foo", "pass");
    mysqli_select_db("foo_db");
                                         
    /* Change user to bar@localhost and default database to bar_db */
    mysqli_change_user($link, "bar", "otherpass", "bar_db");

?>
]]>
      </programlisting>
     </example>
    </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
-->