2003-03-15 23:01:35 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2004-03-16 15:26:37 +00:00
|
|
|
<!-- $Revision: 1.10 $ -->
|
|
|
|
<!-- EN-Revision: 1.9 Maintainer: baoengb Status: ready -->
|
2003-03-15 23:01:35 +00:00
|
|
|
<refentry id="function.mysqli-change-user">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>mysqli_change_user</refname>
|
2004-01-28 23:18:42 +00:00
|
|
|
<refname>mysqli->change_user</refname>
|
2004-03-16 15:26:37 +00:00
|
|
|
<refpurpose>Cambia el usuario de la conexión a la base de datos especificada</refpurpose>
|
2003-03-15 23:01:35 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
2004-03-16 15:26:37 +00:00
|
|
|
<title>Descripción</title>
|
|
|
|
<para>Estilo por procedimientos:</para>
|
2004-01-28 23:18:42 +00:00
|
|
|
<methodsynopsis>
|
|
|
|
<type>bool</type><methodname>mysqli_change_user</methodname>
|
2004-03-16 15:26:37 +00:00
|
|
|
<methodparam><type>object</type><parameter>identificador_de_enlace</parameter></methodparam>
|
|
|
|
<methodparam><type>cadena</type><parameter>usuario</parameter></methodparam>
|
|
|
|
<methodparam><type>cadena</type><parameter>contraseña</parameter></methodparam>
|
|
|
|
<methodparam><type>cadena</type><parameter>base_de_datos</parameter></methodparam>
|
2004-01-28 23:18:42 +00:00
|
|
|
</methodsynopsis>
|
2004-03-16 15:26:37 +00:00
|
|
|
<para>Estilo orientado a objetos (método):</para>
|
2004-01-28 23:18:42 +00:00
|
|
|
<classsynopsis>
|
|
|
|
<ooclass><classname>mysqli</classname></ooclass>
|
2003-03-15 23:01:35 +00:00
|
|
|
<methodsynopsis>
|
2004-01-28 23:18:42 +00:00
|
|
|
<type>bool</type>
|
|
|
|
<methodname>change_user</methodname>
|
2004-03-16 15:26:37 +00:00
|
|
|
<methodparam><type>cadena</type><parameter>usuario</parameter></methodparam>
|
|
|
|
<methodparam><type>cadena</type><parameter>contraseńa</parameter></methodparam>
|
|
|
|
<methodparam><type>cadena</type><parameter>base_de_datos</parameter></methodparam>
|
2003-03-15 23:01:35 +00:00
|
|
|
</methodsynopsis>
|
2004-01-28 23:18:42 +00:00
|
|
|
</classsynopsis>
|
2003-03-15 23:01:35 +00:00
|
|
|
<para>
|
2004-03-16 15:26:37 +00:00
|
|
|
<function>mysqli_change_user</function> Es usada para cambiar el usuario para
|
|
|
|
la conexión de base de datos indicada por el parámetro
|
|
|
|
<parameter>identificador_de_enlace</parameter> y para fijar la actual base de datos a la específicada
|
|
|
|
por el parámetro <parameter>base_de_datos</parameter>.
|
2003-03-15 23:01:35 +00:00
|
|
|
</para>
|
2003-05-23 18:07:24 +00:00
|
|
|
<para>
|
2004-03-16 15:26:37 +00:00
|
|
|
Si se desea, se puede pasar el valor &null; en lugar del parámetro
|
|
|
|
<parameter>base_de_datos</parameter> resultando en solo cambiar el usaurio y no
|
|
|
|
seleccionar la base de datos. Para seleccionar una base de datos en este caso
|
|
|
|
use la función <function>mysqli_select_db</function>.
|
2003-05-13 23:12:16 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
2004-03-16 15:26:37 +00:00
|
|
|
Para poder cambiar de usuario de forma exitosa se debe proveer de un
|
|
|
|
<parameter>usuario</parameter> y <parameter>contraseña</parameter>
|
|
|
|
validos, y tales parámetros debe contar con los suficientes permisos
|
|
|
|
para acceder a la base de datos deseada. Si por cualquier razón la
|
|
|
|
autorización falla, el actual usuario autenticado permanecerá activo.
|
2003-05-13 23:12:16 +00:00
|
|
|
</para>
|
|
|
|
<note>
|
|
|
|
<para>
|
2004-03-16 15:26:37 +00:00
|
|
|
El uso de este comando siempre producirá que la conexión actual
|
|
|
|
a la base de datos se comporte como si fuera una nueva conexión,
|
|
|
|
sin importar si la operación fue completada exitosamente. Este reinicio
|
|
|
|
implica el hacer la restauración no actualizada "rollback" de cualquier
|
|
|
|
transacción activa, cerrar todas las tablas temporales y des-asegurar
|
|
|
|
todas las tablas aseguradas.
|
2003-05-13 23:12:16 +00:00
|
|
|
</para>
|
|
|
|
</note>
|
2004-01-28 23:18:42 +00:00
|
|
|
</refsect1>
|
|
|
|
<refsect1>
|
2004-03-16 15:26:37 +00:00
|
|
|
<title>Valores regresados</title>
|
2004-01-28 23:18:42 +00:00
|
|
|
<para>
|
|
|
|
&return.success;
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
2004-02-19 16:27:40 +00:00
|
|
|
<refsect1>
|
2004-03-16 15:26:37 +00:00
|
|
|
<title>Vea también:</title>
|
2004-02-19 16:27:40 +00:00
|
|
|
<para>
|
|
|
|
<function>mysqli_connect</function>
|
|
|
|
<function>mysqli_select_db</function>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
2004-01-28 23:18:42 +00:00
|
|
|
<refsect1>
|
2004-03-16 15:26:37 +00:00
|
|
|
<title>Ejemplos</title>
|
2003-05-25 19:09:28 +00:00
|
|
|
<example>
|
2004-03-16 15:26:37 +00:00
|
|
|
<title>Estilo orientado a objetos</title>
|
2003-05-25 19:27:11 +00:00
|
|
|
<programlisting role="php">
|
2003-05-25 18:02:46 +00:00
|
|
|
<![CDATA[
|
|
|
|
<?php
|
2004-02-19 16:27:40 +00:00
|
|
|
|
2004-02-25 21:59:16 +00:00
|
|
|
/* connect database test */
|
2004-02-19 16:27:40 +00:00
|
|
|
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
|
|
|
|
|
2004-02-25 21:59:16 +00:00
|
|
|
/* check connection */
|
|
|
|
if (mysqli_connect_errno()) {
|
|
|
|
printf("Connect failed: %s\n", mysqli_connect_error());
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set Variable a */
|
|
|
|
$mysqli->query("SET @a:=1");
|
2003-05-25 18:02:46 +00:00
|
|
|
|
2004-02-25 21:59:16 +00:00
|
|
|
/* reset all and select a new database */
|
|
|
|
$mysqli->change_user("my_user", "my_password", "world");
|
2004-02-19 16:27:40 +00:00
|
|
|
|
|
|
|
if ($result = $mysqli->query("SELECT DATABASE()")) {
|
|
|
|
$row = $result->fetch_row();
|
|
|
|
printf("Default database: %s\n", $row[0]);
|
|
|
|
$result->close();
|
|
|
|
}
|
|
|
|
|
2004-02-25 21:59:16 +00:00
|
|
|
if ($result = $mysqli->query("SELECT @a")) {
|
|
|
|
$row = $result->fetch_row();
|
|
|
|
if ($row[0] === NULL) {
|
|
|
|
printf("Value of variable a is NULL\n");
|
|
|
|
}
|
|
|
|
$result->close();
|
2004-02-19 16:27:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* close connection */
|
|
|
|
$mysqli->close();
|
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
<example>
|
2004-03-16 15:26:37 +00:00
|
|
|
<title>Estilo por procedimientos</title>
|
2004-02-19 16:27:40 +00:00
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
2004-02-25 21:59:16 +00:00
|
|
|
/* connect database test */
|
2004-02-19 16:27:40 +00:00
|
|
|
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
|
|
|
|
|
2004-02-25 21:59:16 +00:00
|
|
|
/* check connection */
|
|
|
|
if (!$link) {
|
|
|
|
printf("Connect failed: %s\n", mysqli_connect_error());
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set Variable a */
|
|
|
|
mysqli_query($link, "SET @a:=1");
|
2004-02-19 16:27:40 +00:00
|
|
|
|
2004-02-25 21:59:16 +00:00
|
|
|
/* reset all and select a new database */
|
|
|
|
mysqli_change_user($link, "my_user", "my_password", "world");
|
2004-02-19 16:27:40 +00:00
|
|
|
|
|
|
|
if ($result = mysqli_query($link, "SELECT DATABASE()")) {
|
|
|
|
$row = mysqli_fetch_row($result);
|
|
|
|
printf("Default database: %s\n", $row[0]);
|
|
|
|
mysqli_free_result($result);
|
|
|
|
}
|
|
|
|
|
2004-02-25 21:59:16 +00:00
|
|
|
if ($result = mysqli_query($link, "SELECT @a")) {
|
|
|
|
$row = mysqli_fetch_row($result);
|
|
|
|
if ($row[0] === NULL) {
|
|
|
|
printf("Value of variable a is NULL\n");
|
|
|
|
}
|
|
|
|
mysqli_free_result($result);
|
2004-02-19 16:27:40 +00:00
|
|
|
}
|
2003-05-25 18:02:46 +00:00
|
|
|
|
2004-02-19 16:27:40 +00:00
|
|
|
/* close connection */
|
|
|
|
mysqli_close($link);
|
2003-05-25 18:02:46 +00:00
|
|
|
?>
|
|
|
|
]]>
|
2004-02-25 21:59:16 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
<para>
|
2004-03-16 15:26:37 +00:00
|
|
|
Los ejemplos anteriores producirán la siguiente salida:
|
2003-05-25 18:02:46 +00:00
|
|
|
</para>
|
2004-02-25 21:59:16 +00:00
|
|
|
<screen>
|
|
|
|
<![CDATA[
|
|
|
|
Default database: world
|
|
|
|
Value of variable a is NULL
|
|
|
|
]]>
|
|
|
|
</screen>
|
2003-03-15 23:01:35 +00:00
|
|
|
</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
|
|
|
|
-->
|