mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-21 11:28:55 +00:00
119 lines
3.5 KiB
XML
119 lines
3.5 KiB
XML
![]() |
<?xml version="1.0" encoding="iso-8859-1"?>
|
||
|
<!-- $Revision: 1.1.1.1 $ -->
|
||
|
<refentry id="function.maxdb-change-user">
|
||
|
<refnamediv>
|
||
|
<refname>maxdb_change_user</refname>
|
||
|
<refpurpose>Changes the user of the specified database connection</refpurpose>
|
||
|
</refnamediv>
|
||
|
<refsect1>
|
||
|
<title>Description</title>
|
||
|
<para>Procedural style:</para>
|
||
|
<methodsynopsis>
|
||
|
<type>bool</type><methodname>maxdb_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>maxdb_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>
|
||
|
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>
|
||
|
</refsect1>
|
||
|
<refsect1>
|
||
|
<title>Return Values</title>
|
||
|
<para>
|
||
|
&return.success;
|
||
|
</para>
|
||
|
</refsect1>
|
||
|
<refsect1>
|
||
|
<title>See also:</title>
|
||
|
<para>
|
||
|
<function>maxdb_connect</function>
|
||
|
<function>maxdb_select_db</function>
|
||
|
</para>
|
||
|
</refsect1>
|
||
|
<refsect1>
|
||
|
<title>Example</title>
|
||
|
<example>
|
||
|
<title>Procedural style</title>
|
||
|
<programlisting role="php">
|
||
|
<![CDATA[
|
||
|
<?php
|
||
|
$link = maxdb_connect("localhost", "MONA", "RED");
|
||
|
|
||
|
/* check connection */
|
||
|
if (!$link) {
|
||
|
printf("Connect failed: %s\n", maxdb_connect_error());
|
||
|
exit();
|
||
|
}
|
||
|
|
||
|
if ($result = maxdb_query($link, "SELECT * FROM dual")) {
|
||
|
$row = maxdb_fetch_row($result);
|
||
|
printf("Result: %s\n", $row[0]);
|
||
|
maxdb_free_result($result);
|
||
|
}
|
||
|
|
||
|
/* reset all and select a new database */
|
||
|
if (!maxdb_change_user($link, $user, $passwd, "XXXXXXX")) {
|
||
|
printf("Database not running\n");
|
||
|
} else {
|
||
|
printf("Database running\n");
|
||
|
}
|
||
|
|
||
|
/* close connection */
|
||
|
maxdb_close($link);
|
||
|
?>
|
||
|
]]>
|
||
|
</programlisting>
|
||
|
</example>
|
||
|
<para>
|
||
|
The above examples would produce the following output:
|
||
|
</para>
|
||
|
<screen>
|
||
|
<![CDATA[
|
||
|
Result: a
|
||
|
PHP Warning: maxdb_change_user(): -10709 Connection failed <...>
|
||
|
Database not running
|
||
|
PHP Warning: maxdb_close(): -10821 Session not connected <...>
|
||
|
]]>
|
||
|
</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
|
||
|
-->
|