function.ibase-connect.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 273 行
HTML
273 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Open a connection to an InterBase database</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ibase-commit.html">ibase_commit</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ibase-db-info.html">ibase_db_info</a></div> <div class="up"><a href="ref.ibase.html">Firebird/InterBase Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.ibase-connect" class="refentry"> <div class="refnamediv"> <h1 class="refname">ibase_connect</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">ibase_connect</span> — <span class="dc-title">Open a connection to an InterBase database</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">resource</span> <span class="methodname"><b><b>ibase_connect</b></b></span> ([ <span class="methodparam"><span class="type">string</span> <tt class="parameter">$database</tt></span> [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$username</tt></span> [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$password</tt></span> [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$charset</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$buffers</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$dialect</tt></span> [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$role</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$sync</tt></span> ]]]]]]]] )</div> <p class="para rdfs-comment"> Establishes a connection to an InterBase server. </p> <p class="para"> In case a second call is made to <b>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" class="function">ibase_close()</a>. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">database</tt></i></span> <dd> <p class="para"> The <i><tt class="parameter">database</tt></i> 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. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">username</tt></i></span> <dd> <p class="para"> The user name. Can be set with the <i>ibase.default_user</i> <var class="filename">php.ini</var> directive. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">password</tt></i></span> <dd> <p class="para"> The password for <i><tt class="parameter">username</tt></i>. Can be set with the <i>ibase.default_password</i> <var class="filename">php.ini</var> directive. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">charset</tt></i></span> <dd> <p class="para"> <i><tt class="parameter">charset</tt></i> is the default character set for a database. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">buffers</tt></i></span> <dd> <p class="para"> <i><tt class="parameter">buffers</tt></i> is the number of database buffers to allocate for the server-side cache. If 0 or omitted, server chooses its own default. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">dialect</tt></i></span> <dd> <p class="para"> <i><tt class="parameter">dialect</tt></i> selects the default SQL dialect for any statement executed within a connection, and it defaults to the highest one supported by client libraries. Functional only with InterBase 6 and up. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">role</tt></i></span> <dd> <p class="para"> Functional only with InterBase 5 and up. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">sync</tt></i></span> <dd> <p class="para"> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns an InterBase link identifier on success, or <b><tt>FALSE</tt></b> on error. </p> </div> <div class="refsect1 errors"> <h3 class="title">Errors/Exceptions</h3> <p class="para"> 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" class="function">ibase_query()</a> you must set the character set (i.e. ISO8859_1 or your current character set). </p> </div> <div class="refsect1 changelog"> <h3 class="title">ChangeLog</h3> <p class="para"> <table class="informaltable"> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Version</th> <th colspan="1">Description</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">4.0.0</td> <td colspan="1" rowspan="1" align="left"> The <i><tt class="parameter">buffers</tt></i>, <i><tt class="parameter">dialect</tt></i> and <i><tt class="parameter">role</tt></i> parameters were added </td> </tr> </tbody> </colgroup> </table> </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 <b>ibase_connect()</b> example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$host </span><span style="color: #007700">= </span><span style="color: #DD0000">'localhost:/path/to/your.gdb'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$dbh </span><span style="color: #007700">= </span><span style="color: #0000BB">ibase_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$host</span><span style="color: #007700">, </span><span style="color: #0000BB">$username</span><span style="color: #007700">, </span><span style="color: #0000BB">$password</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$stmt </span><span style="color: #007700">= </span><span style="color: #DD0000">'SELECT * FROM tblname'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$sth </span><span style="color: #007700">= </span><span style="color: #0000BB">ibase_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbh</span><span style="color: #007700">, </span><span style="color: #0000BB">$stmt</span><span style="color: #007700">);<br />while (</span><span style="color: #0000BB">$row </span><span style="color: #007700">= </span><span style="color: #0000BB">ibase_fetch_object</span><span style="color: #007700">(</span><span style="color: #0000BB">$sth</span><span style="color: #007700">)) {<br /> echo </span><span style="color: #0000BB">$row</span><span style="color: #007700">-></span><span style="color: #0000BB">email</span><span style="color: #007700">, </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">ibase_free_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$sth</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ibase_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbh</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.ibase-pconnect.html" class="function" rel="rdfs-seeAlso">ibase_pconnect()</a></li> <li class="member"><a href="function.ibase-close.html" class="function" rel="rdfs-seeAlso">ibase_close()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ibase-commit.html">ibase_commit</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ibase-db-info.html">ibase_db_info</a></div> <div class="up"><a href="ref.ibase.html">Firebird/InterBase Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?