Sophie

Sophie

distrib > PLD > ac > amd64 > media > dist > by-pkgid > dd8ef74e7a184506d40e4328053fb785 > files > 3112

php-manual-ro-20051028-1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>sqlite_open</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Manual PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="SQLite"
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=ISO-8859-2"></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 PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.sqlite-num-rows.html"
ACCESSKEY="P"
>Înapoi</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"
>Înainte</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="AEN105723"
></A
><P
>    (PHP 5)</P
>sqlite_open&nbsp;--&nbsp;Opens a SQLite database.  Will create the database if it does not exist</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN105726"
></A
><H2
>Description</H2
>resource <B
CLASS="methodname"
>sqlite_open</B
> ( string filename [, int mode [, string &#38;error_message]])<BR
></BR
><P
>&#13;   Returns a resource (database handle) on success, <TT
CLASS="constant"
><B
>FALSE</B
></TT
> on error.
  </P
><P
>&#13;   The <VAR
CLASS="parameter"
>filename</VAR
> parameter is the name of the
   database.  It can be a relative or absolute path to the file that sqlite
   will use to store your data.  If the file does not exist, sqlite will
   attempt to create it.  You <SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>MUST</I
></SPAN
> have write
   permissions to the file if you want to insert data or modify the database
   schema.
  </P
><P
>&#13;   The <VAR
CLASS="parameter"
>mode</VAR
> parameter specifies the mode of the file and is
   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 <VAR
CLASS="literal"
>0666</VAR
> and this is the
   recommended value to use if you need access to the
   <VAR
CLASS="parameter"
>errmessage</VAR
> parameter.
  </P
><P
>&#13;   <VAR
CLASS="parameter"
>errmessage</VAR
> is 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
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN105752"
></A
><P
><B
>Exemplu 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
CLASS="tip"
><BLOCKQUOTE
CLASS="tip"
><P
><B
>Indica&#254;ie: </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
    <VAR
CLASS="literal"
>Multi-Threading And SQLite</VAR
>. 
   </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="tip"
><BLOCKQUOTE
CLASS="tip"
><P
><B
>Indica&#254;ie: </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
>Not&#227;: </B
>
    Starting with SQLite library version 2.8.2, you can specify
    <VAR
CLASS="literal"
>:memory:</VAR
> as the <VAR
CLASS="parameter"
>filename</VAR
> 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 <VAR
CLASS="literal"
>ATTACH DATABASE</VAR
> SQL
    statement to load other databases and move and query data between them.
   </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Not&#227;: </B
>
    SQLite is <A
HREF="features.safe-mode.html#ini.safe-mode"
>safe mode</A
> and open_basedir aware.
   </P
></BLOCKQUOTE
></DIV
><P
>&#13;   See also <A
HREF="function.sqlite-popen.html"
><B
CLASS="function"
>sqlite_popen()</B
></A
>,
   <A
HREF="function.sqlite-close.html"
><B
CLASS="function"
>sqlite_close()</B
></A
> and
   <A
HREF="function.sqlite-query.html"
><B
CLASS="function"
>sqlite_query()</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.sqlite-num-rows.html"
ACCESSKEY="P"
>Înapoi</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Acas&#227;</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.sqlite-popen.html"
ACCESSKEY="N"
>Înainte</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"
>Sus</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>sqlite_popen</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>