<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Opens a database</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.dbase-numrecords.html">dbase_numrecords</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.dbase-pack.html">dbase_pack</a></div> <div class="up"><a href="ref.dbase.html">dBase Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.dbase-open" class="refentry"> <div class="refnamediv"> <h1 class="refname">dbase_open</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">dbase_open</span> — <span class="dc-title">Opens a database</span></p> </div> <div class="refsect1 description" id="refsect1-function.dbase-open-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">int</span> <span class="methodname"><strong>dbase_open</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span> , <span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code></span> )</div> <p class="para rdfs-comment"> <span class="function"><strong>dbase_open()</strong></span> opens a dBase database with the given access mode. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">When <a href="features.safe-mode.html" class="link">safe mode</a> is enabled, PHP checks whether the files or directories being operated upon have the same UID (owner) as the script that is being executed.</span></p></blockquote> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para">This function is affected by <a href="ini.core.html#ini.open-basedir" class="link">open_basedir</a>.</p></p></blockquote> </div> <div class="refsect1 parameters" id="refsect1-function.dbase-open-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">filename</code></em></span> <dd> <p class="para"> The name of the database. It can be a relative or absolute path to the file where dBase will store your data. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">mode</code></em></span> <dd> <p class="para"> An integer which correspond to those for the <strong class="command">open()</strong> system call (Typically 0 means read-only, 1 means write-only, and 2 means read and write). </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> You can't open a dBase file in write-only mode as the function will fail to read the headers information and thus you can't use 1 as <em><code class="parameter">mode</code></em>. </p> </p></blockquote> </dd> </dt> </dl> </p> </div> <div class="refsect1 examples" id="refsect1-function.dbase-open-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-1101"> <p><strong>Example #1 Opening a dBase database file</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /><br /></span><span style="color: #FF8000">// open in read-only mode<br /></span><span style="color: #0000BB">$db </span><span style="color: #007700">= </span><span style="color: #0000BB">dbase_open</span><span style="color: #007700">(</span><span style="color: #DD0000">'/tmp/test.dbf'</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /><br />if (</span><span style="color: #0000BB">$db</span><span style="color: #007700">) {<br /> </span><span style="color: #FF8000">// read some data ..<br /> <br /> </span><span style="color: #0000BB">dbase_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$db</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.dbase-open-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns a database link identifier if the database is successfully opened, or <strong><code>FALSE</code></strong> if an error occurred. </p> </div> <div class="refsect1 seealso" id="refsect1-function.dbase-open-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.dbase-create.html" class="function" rel="rdfs-seeAlso">dbase_create()</a> - Creates a database</span></li> <li class="member"> <span class="function"><a href="function.dbase-close.html" class="function" rel="rdfs-seeAlso">dbase_close()</a> - Closes a database</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.dbase-numrecords.html">dbase_numrecords</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.dbase-pack.html">dbase_pack</a></div> <div class="up"><a href="ref.dbase.html">dBase Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>