Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 1636

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>ibase_connect</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="Firebird/InterBase Functions"
HREF="ref.ibase.html"><LINK
REL="PREVIOUS"
TITLE="ibase_commit"
HREF="function.ibase-commit.html"><LINK
REL="NEXT"
TITLE="ibase_db_info"
HREF="function.ibase-db-info.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></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"
>PHP 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.ibase-commit.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.ibase-db-info.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.ibase-connect"
></A
>ibase_connect</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN56870"
></A
><P
>    (PHP 3 &#62;= 3.0.6, PHP 4, PHP 5)</P
>ibase_connect&nbsp;--&nbsp;
     Open a connection to an InterBase database
    </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN56873"
></A
><H2
>Description</H2
>resource <B
CLASS="methodname"
>ibase_connect</B
> ( [string database [, string username [, string password [, string charset [, int buffers [, int dialect [, string role [, int sync]]]]]]]] )<BR
></BR
><P
>&#13;     Establishes a connection to an InterBase server.
     The <CODE
CLASS="parameter"
>database</CODE
> argument
     has to be a valid path to database file on the server it resides on.
     If the server is not local, it must be prefixed with either
     'hostname:' (TCP/IP), '//hostname/' (NetBEUI) or 'hostname@' (IPX/SPX),
     depending on the connection protocol used. <CODE
CLASS="parameter"
>username</CODE
>
     and <CODE
CLASS="parameter"
>password</CODE
> can also
     be specified with PHP configuration directives ibase.default_user and
     ibase.default_password. <CODE
CLASS="parameter"
>charset</CODE
> is the default
     character set for a database. <CODE
CLASS="parameter"
>buffers</CODE
> is the number
     of database buffers to allocate for the server-side cache. If 0 or omitted,
     server chooses its own default. <CODE
CLASS="parameter"
>dialect</CODE
> selects
     the default SQL dialect for any statement executed within a connection,
     and it defaults to the highest one supported by client libraries.
    </P
><P
>&#13;     In case a second call is made to
     <B
CLASS="function"
>ibase_connect()</B
> with the same arguments, no new link
     will be established, but instead, the link identifier of the already opened
     link will be returned. The link to the server will be closed as soon as the
     execution of the script ends, unless it's closed earlier by explicitly calling
     <A
HREF="function.ibase-close.html"
><B
CLASS="function"
>ibase_close()</B
></A
>. 
     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN56912"
></A
><P
><B
>例 1. <B
CLASS="function"
>ibase_connect()</B
> example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;$host </font><font color="#007700">= </font><font color="#DD0000">'localhost:/path/to/your.gdb'</font><font color="#007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$dbh </font><font color="#007700">= </font><font color="#0000BB">ibase_connect</font><font color="#007700">(</font><font color="#0000BB">$host</font><font color="#007700">, </font><font color="#0000BB">$username</font><font color="#007700">, </font><font color="#0000BB">$password</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$stmt </font><font color="#007700">= </font><font color="#DD0000">'SELECT * FROM tblname'</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$sth </font><font color="#007700">= </font><font color="#0000BB">ibase_query</font><font color="#007700">(</font><font color="#0000BB">$dbh</font><font color="#007700">, </font><font color="#0000BB">$stmt</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;while (</font><font color="#0000BB">$row </font><font color="#007700">= </font><font color="#0000BB">ibase_fetch_object</font><font color="#007700">(</font><font color="#0000BB">$sth</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#0000BB">$row</font><font color="#007700">-&gt;</font><font color="#0000BB">email</font><font color="#007700">, </font><font color="#DD0000">"\n"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">ibase_free_result</font><font color="#007700">(</font><font color="#0000BB">$sth</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">ibase_close</font><font color="#007700">(</font><font color="#0000BB">$dbh</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
      The optional <CODE
CLASS="parameter"
>buffers</CODE
> parameter was added in 
      PHP 4.0.0.
     </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
      The optional <CODE
CLASS="parameter"
>dialect</CODE
> parameter was added in PHP
      4.0.0 and is functional only with InterBase 6 and up.
     </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
      The optional <CODE
CLASS="parameter"
>role</CODE
> parameter was added in PHP
      4.0.0 and is functional only with InterBase 5 and up.
     </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
      If you get some error like "arithmetic exception, numeric overflow, 
      or string truncation. Cannot transliterate character between character
      sets" (this occurs when you try use some character with accents) 
      when using this and after <A
HREF="function.ibase-query.html"
><B
CLASS="function"
>ibase_query()</B
></A
> you must
      set the character set (i.e. ISO8859_1 or your current character set).
     </P
></BLOCKQUOTE
></DIV
><P
>&#13;     See also 
     <A
HREF="function.ibase-pconnect.html"
><B
CLASS="function"
>ibase_pconnect()</B
></A
> and
     <A
HREF="function.ibase-close.html"
><B
CLASS="function"
>ibase_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.ibase-commit.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.ibase-db-info.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>ibase_commit</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.ibase.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>ibase_db_info</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>