php-doc-en/reference/maxdb/functions/maxdb-change-user.xml
Thomas Simenec 2ec5f57850 update docu
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@184408 c90b9560-bf6c-de11-be94-00142212c4b1
2005-04-15 17:53:21 +00:00

162 lines
4.7 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<refentry id="function.maxdb-change-user">
<refnamediv>
<refname>maxdb_change_user</refname>
<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>Object oriented style (method):</para>
<classsynopsis>
<ooclass><classname>maxdb</classname></ooclass>
<methodsynopsis>
<type>bool</type>
<methodname>change_user</methodname>
<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>
</classsynopsis>
<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>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
/* connect database test */
$maxdb = new maxdb("localhost", "MONA", "RED", "DEMODB");
/* check connection */
if (maxdb_connect_errno()) {
printf("Connect failed: %s\n", maxdb_connect_error());
exit();
}
if ($result = $maxdb->query("SELECT * FROM dual")) {
$row = $result->fetch_row();
printf("Result: %s\n", $row[0]);
$result->free();
}
/* reset all and select a new database */
if (!$maxdb->change_user("DBADMIN", "SECRET", "DEMODB")) {
printf("Database not running\n");
} else {
printf("Database running\n");
}
/* close connection */
$maxdb->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = maxdb_connect("localhost", "MONA", "RED", "DEMODB");
/* 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, "DBADMIN", "SECRET", "DEMODB")) {
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
Database running
]]>
</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
-->