Sophie

Sophie

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

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
>sqlite_open</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="SQLite Functions"
HREF="ref.sqlite.html"><LINK
REL="PREVIOUS"
TITLE="sqlite_num_rows"
HREF="function.sqlite-num-rows.html"><LINK
REL="NEXT"
TITLE="sqlite_popen"
HREF="function.sqlite-popen.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.sqlite-num-rows.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.sqlite-popen.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.sqlite-open"
></A
>sqlite_open</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN217551"
></A
><P
>    (PHP 5)</P
>sqlite_open&nbsp;--&nbsp;Opens a SQLite database and create the database if it does not exist</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN217554"
></A
><H2
>说明</H2
>resource <B
CLASS="methodname"
>sqlite_open</B
> ( string filename [, int mode [, string &#38;error_message]] )<BR
></BR
><P
>Object oriented style (constructor):</P
>class <B
CLASS="classname"
>SQLiteDatabase</B
> { <BR
></BR
><B
CLASS="methodname"
>__construct</B
> ( string filename [, int mode [, string &#38;error_message]] )<BR
></BR
>}<P
>&#13;   Opens a SQLite database or creates the database if it does not exist.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN217584"
></A
><H2
>参数</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>filename</CODE
></DT
><DD
><P
>&#13;       The filename of the SQLite database.  If the file does not exist, SQLite
       will attempt to create it.  PHP must have write permissions to the file
       if data is inserted, the database schema is modified or to create the
       database if it does not exist.
      </P
></DD
><DT
><CODE
CLASS="parameter"
>mode</CODE
></DT
><DD
><P
>&#13;       The mode of the file. Intended to be used to open the database in
       read-only mode.  Presently, this parameter is ignored by the sqlite
       library.  The default value for mode is the octal value
       <TT
CLASS="literal"
>0666</TT
> and this is the recommended value.
      </P
></DD
><DT
><CODE
CLASS="parameter"
>error_message</CODE
></DT
><DD
><P
>&#13;       Passed by reference and is set to hold a descriptive error message
       explaining why the database could not be opened if there was an error.
      </P
></DD
></DL
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN217604"
></A
><H2
>返回值</H2
><P
>&#13;   Returns a resource (database handle) on success, <TT
CLASS="constant"
><B
>FALSE</B
></TT
> on error.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN217608"
></A
><H2
>范例</H2
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN217611"
></A
><P
><B
>例 1. <B
CLASS="function"
>sqlite_open()</B
> example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#007700">if (</font><font color="#0000BB">$db </font><font color="#007700">= </font><font color="#0000BB">sqlite_open</font><font color="#007700">(</font><font color="#DD0000">'mysqlitedb'</font><font color="#007700">, </font><font color="#0000BB">0666</font><font color="#007700">, </font><font color="#0000BB">$sqliteerror</font><font color="#007700">)) { <br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">sqlite_query</font><font color="#007700">(</font><font color="#0000BB">$db</font><font color="#007700">, </font><font color="#DD0000">'CREATE TABLE foo (bar varchar(10))'</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">sqlite_query</font><font color="#007700">(</font><font color="#0000BB">$db</font><font color="#007700">, </font><font color="#DD0000">"INSERT INTO foo VALUES ('fnord')"</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$result </font><font color="#007700">= </font><font color="#0000BB">sqlite_query</font><font color="#007700">(</font><font color="#0000BB">$db</font><font color="#007700">, </font><font color="#DD0000">'select bar from foo'</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">var_dump</font><font color="#007700">(</font><font color="#0000BB">sqlite_fetch_array</font><font color="#007700">(</font><font color="#0000BB">$result</font><font color="#007700">)); <br />} else {<br />&nbsp;&nbsp;&nbsp;&nbsp;die(</font><font color="#0000BB">$sqliteerror</font><font color="#007700">);<br />}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN217615"
></A
><H2
>注释</H2
><DIV
CLASS="tip"
><BLOCKQUOTE
CLASS="tip"
><P
><B
>提示: </B
>
    On Unix platforms, SQLite is sensitive to scripts that use the fork() system call.  If you
    do have such a script, it is recommended that you close the handle prior
    to forking and then re-open it in the child and/or parent.
    For more information on this issue, see 
    <A
HREF="http://sqlite.org/c_interface.html"
TARGET="_top"
>The C language interface
    to the SQLite library</A
> in the section entitled
    <TT
CLASS="literal"
>Multi-Threading And SQLite</TT
>. 
   </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="tip"
><BLOCKQUOTE
CLASS="tip"
><P
><B
>提示: </B
>
    It is not recommended to work with SQLite databases mounted on NFS
    partitions.  Since NFS is notoriously bad when it comes to locking you
    may find that you cannot even open the database at all, and if it
    succeeds, the locking behaviour may be undefined.
   </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
    Starting with SQLite library version 2.8.2, you can specify
    <TT
CLASS="literal"
>:memory:</TT
> as the <CODE
CLASS="parameter"
>filename</CODE
> to
    create a database that lives only in the memory of the computer.
    This is useful mostly for temporary processing, as the in-memory
    database will be destroyed when the process ends.  It can also be
    useful when coupled with the <TT
CLASS="literal"
>ATTACH DATABASE</TT
> SQL
    statement to load other databases and move and query data between them.
   </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
    SQLite is <A
HREF="features.safe-mode.html#ini.safe-mode"
>安全模式</A
> and open_basedir aware.
   </P
></BLOCKQUOTE
></DIV
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN217631"
></A
><H2
>参见</H2
><P
>&#13;   <P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
><A
HREF="function.sqlite-popen.html"
><B
CLASS="function"
>sqlite_popen()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.sqlite-close.html"
><B
CLASS="function"
>sqlite_close()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.sqlite-factory.html"
><B
CLASS="function"
>sqlite_factory()</B
></A
></TD
></TR
></TBODY
></TABLE
><P
></P
>
  </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.sqlite-num-rows.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.sqlite-popen.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>sqlite_num_rows</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.sqlite.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>sqlite_popen</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>