Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > a34ed6838d4b29d38abd504392a4a797 > files > 409

php-manual-es-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>dbx_connect</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Manual de PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="dbx functions"
HREF="ref.dbx.html"><LINK
REL="PREVIOUS"
TITLE="dbx_compare"
HREF="function.dbx-compare.html"><LINK
REL="NEXT"
TITLE="dbx_error"
HREF="function.dbx-error.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Manual de PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.dbx-compare.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.dbx-error.html"
ACCESSKEY="N"
>Siguiente</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.dbx-connect"
></A
>dbx_connect</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN13076"
></A
><P
>    (PHP 4 &#62;= 4.0.6)</P
>dbx_connect&nbsp;--&nbsp;Open a connection/database</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN13079"
></A
><H2
>Description</H2
>object <B
CLASS="methodname"
>dbx_connect</B
> ( mixed module, string host, string database, string username, string password [, int persistent])<BR
></BR
><P
>&#13;     <B
CLASS="function"
>dbx_connect()</B
> returns an object on success, <TT
CLASS="constant"
><B
>FALSE</B
></TT
> on
     error. If a connection has been made but the database could not be 
     selected, the connection is closed and <TT
CLASS="constant"
><B
>FALSE</B
></TT
> is returned. 
     The <TT
CLASS="parameter"
><I
>persistent</I
></TT
> parameter can be set to 
     <TT
CLASS="constant"
><B
>DBX_PERSISTENT</B
></TT
>, if so, a persistent connection will be
     created.
    </P
><P
>&#13;     The <TT
CLASS="parameter"
><I
>module</I
></TT
> parameter can be either a string or a
     constant, though the latter form is preferred. The possible values are 
     given below, but keep in mind that they only work if the module is 
     actually loaded.
    </P
><P
>&#13;     <P
></P
><UL
><LI
><P
>&#13;        <TT
CLASS="constant"
><B
>DBX_MYSQL</B
></TT
> or "mysql"
       </P
></LI
><LI
><P
>&#13;        <TT
CLASS="constant"
><B
>DBX_ODBC</B
></TT
> or "odbc"
       </P
></LI
><LI
><P
>&#13;        <TT
CLASS="constant"
><B
>DBX_PGSQL</B
></TT
> or "pgsql"
       </P
></LI
><LI
><P
>&#13;        <TT
CLASS="constant"
><B
>DBX_MSSQL</B
></TT
> or "mssql"
       </P
></LI
><LI
><P
>&#13;        <TT
CLASS="constant"
><B
>DBX_FBSQL</B
></TT
> or "fbsql" (available from PHP 4.1.0)
       </P
></LI
><LI
><P
>&#13;        <TT
CLASS="constant"
><B
>DBX_SYBASECT</B
></TT
> or "sybase_ct" (available from PHP
        4.2.0)
       </P
></LI
><LI
><P
>&#13;        <TT
CLASS="constant"
><B
>DBX_OCI8</B
></TT
> or "oci8" (available from PHP 4.3.0)
       </P
></LI
></UL
>
    </P
><P
>&#13;     The <TT
CLASS="parameter"
><I
>host</I
></TT
>, <TT
CLASS="parameter"
><I
>database</I
></TT
>, 
     <TT
CLASS="parameter"
><I
>username</I
></TT
> and <TT
CLASS="parameter"
><I
>password</I
></TT
> 
     parameters are expected, but not always used depending on the connect
     functions for the abstracted module.
    </P
><P
>&#13;     The returned <TT
CLASS="varname"
>object</TT
> has three properties:
     <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><SPAN
CLASS="property"
>database</SPAN
></DT
><DD
><P
>&#13;         It is the name of the currently selected database. 
        </P
></DD
><DT
><SPAN
CLASS="property"
>handle</SPAN
></DT
><DD
><P
>&#13;         It is a valid handle for the connected database, and as such it can be
         used in module-specific functions (if required).
         <DIV
CLASS="informalexample"
><A
NAME="AEN13151"
></A
><P
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>$link = dbx_connect (DBX_MYSQL, "localhost", "db", "username", "password");
mysql_close ($link-&#62;handle); // dbx_close($link) would be better here</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
>
        </P
></DD
><DT
><SPAN
CLASS="property"
>module</SPAN
></DT
><DD
><P
>&#13;         It is used internally by dbx only, and is actually the module number
         mentioned above.
        </P
></DD
></DL
></DIV
>
    </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN13159"
></A
><P
><B
>Ejemplo 1. <B
CLASS="function"
>dbx_connect()</B
> example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>&#60;?php
$link = dbx_connect (DBX_ODBC, "", "db", "username", "password", DBX_PERSISTENT)
    or die ("Could not connect");

print ("Connected successfully");
dbx_close ($link);
?&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
     <DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>
       Always refer to the module-specific documentation as well.
      </P
></BLOCKQUOTE
></DIV
>
    </P
><P
>&#13;     See also: <A
HREF="function.dbx-close.html"
><B
CLASS="function"
>dbx_close()</B
></A
>.
    </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.dbx-compare.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Inicio</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.dbx-error.html"
ACCESSKEY="N"
>Siguiente</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>dbx_compare</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.dbx.html"
ACCESSKEY="U"
>Subir</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>dbx_error</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>