2010-03-28 22:10:10 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2009-07-11 09:02:41 +00:00
|
|
|
<!-- $Revision$ -->
|
2007-06-20 22:25:43 +00:00
|
|
|
<refentry xml:id="function.sqlite-exec" xmlns="http://docbook.org/ns/docbook">
|
2004-05-13 14:27:30 +00:00
|
|
|
<refnamediv>
|
|
|
|
<refname>sqlite_exec</refname>
|
2005-01-12 08:56:59 +00:00
|
|
|
<refname>SQLiteDatabase->exec</refname>
|
|
|
|
<refpurpose>Executes a result-less query against a given database</refpurpose>
|
2004-05-13 14:27:30 +00:00
|
|
|
</refnamediv>
|
2005-02-21 00:31:07 +00:00
|
|
|
|
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
2004-05-13 14:27:30 +00:00
|
|
|
<methodsynopsis>
|
2004-05-13 14:29:46 +00:00
|
|
|
<type>bool</type><methodname>sqlite_exec</methodname>
|
2004-05-13 14:36:08 +00:00
|
|
|
<methodparam><type>resource</type><parameter>dbhandle</parameter></methodparam>
|
2004-05-13 14:27:30 +00:00
|
|
|
<methodparam><type>string</type><parameter>query</parameter></methodparam>
|
2005-09-09 21:42:13 +00:00
|
|
|
<methodparam choice="opt"><type>string</type><parameter role="reference">error_msg</parameter></methodparam>
|
2004-05-13 14:27:30 +00:00
|
|
|
</methodsynopsis>
|
2004-05-13 14:36:08 +00:00
|
|
|
<methodsynopsis>
|
|
|
|
<type>bool</type><methodname>sqlite_exec</methodname>
|
|
|
|
<methodparam><type>string</type><parameter>query</parameter></methodparam>
|
|
|
|
<methodparam><type>resource</type><parameter>dbhandle</parameter></methodparam>
|
|
|
|
</methodsynopsis>
|
2012-01-11 06:50:17 +00:00
|
|
|
<para>&style.oop; (method):</para>
|
2005-01-12 08:56:59 +00:00
|
|
|
<classsynopsis>
|
|
|
|
<ooclass><classname>SQLiteDatabase</classname></ooclass>
|
|
|
|
<methodsynopsis>
|
2005-09-02 18:03:16 +00:00
|
|
|
<type>bool</type><methodname>queryExec</methodname>
|
2005-01-12 08:56:59 +00:00
|
|
|
<methodparam><type>string</type><parameter>query</parameter></methodparam>
|
2005-09-09 21:42:13 +00:00
|
|
|
<methodparam choice="opt"><type>string</type><parameter role="reference">error_msg</parameter></methodparam>
|
2005-01-12 08:56:59 +00:00
|
|
|
</methodsynopsis>
|
|
|
|
</classsynopsis>
|
2004-05-13 14:36:08 +00:00
|
|
|
<para>
|
|
|
|
Executes an SQL statement given by the <parameter>query</parameter> against
|
|
|
|
a given database handle (specified by the <parameter>dbhandle</parameter>
|
|
|
|
parameter).
|
|
|
|
</para>
|
|
|
|
<warning>
|
|
|
|
<simpara>
|
|
|
|
SQLite <emphasis>will</emphasis> execute multiple queries separated by
|
|
|
|
semicolons, so you can use it to execute a batch of SQL that you have
|
|
|
|
loaded from a file or have embedded in a script.
|
|
|
|
</simpara>
|
|
|
|
</warning>
|
2005-02-21 00:31:07 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="parameters">
|
|
|
|
&reftitle.parameters;
|
|
|
|
<para>
|
|
|
|
<variablelist>
|
2005-09-09 21:42:13 +00:00
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>dbhandle</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The SQLite Database resource; returned from
|
|
|
|
<function>sqlite_open</function> when used procedurally. This parameter
|
|
|
|
is not required when using the object-oriented method.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2005-02-21 00:31:07 +00:00
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>query</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The query to be executed.
|
|
|
|
</para>
|
2009-07-30 12:22:29 +00:00
|
|
|
<para>
|
|
|
|
Data inside the query should be <link
|
|
|
|
linkend="function.sqlite-escape-string">properly escaped</link>.
|
|
|
|
</para>
|
2005-02-21 00:31:07 +00:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
2005-09-09 21:42:13 +00:00
|
|
|
<term><parameter>error_msg</parameter></term>
|
2005-02-21 00:31:07 +00:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2005-09-09 21:42:13 +00:00
|
|
|
The specified variable will be filled if an error occurs. This is
|
|
|
|
specially important because SQL syntax errors can't be fetched using
|
|
|
|
the <function>sqlite_last_error</function> function.
|
2005-02-21 00:31:07 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</para>
|
|
|
|
&sqlite.param-compat;
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
&reftitle.returnvalues;
|
|
|
|
<para>
|
|
|
|
This function will return a boolean result; &true; for success or &false; for failure.
|
|
|
|
If you need to run a query that returns rows, see <function>sqlite_query</function>.
|
|
|
|
</para>
|
|
|
|
&sqlite.case-fold;
|
|
|
|
</refsect1>
|
|
|
|
|
2005-09-09 21:42:13 +00:00
|
|
|
<refsect1 role="changelog">
|
|
|
|
&reftitle.changelog;
|
|
|
|
<para>
|
|
|
|
<informaltable>
|
|
|
|
<tgroup cols="2">
|
|
|
|
<thead>
|
|
|
|
<row>
|
|
|
|
<entry>&Version;</entry>
|
|
|
|
<entry>&Description;</entry>
|
|
|
|
</row>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<row>
|
|
|
|
<entry>5.1.0</entry>
|
|
|
|
<entry>
|
|
|
|
Added the <parameter>error_msg</parameter> parameter
|
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
</tbody>
|
|
|
|
</tgroup>
|
|
|
|
</informaltable>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
|
2005-02-21 00:31:07 +00:00
|
|
|
<refsect1 role="examples">
|
|
|
|
&reftitle.examples;
|
2005-01-14 05:42:48 +00:00
|
|
|
<para>
|
|
|
|
<example>
|
2005-02-21 00:31:07 +00:00
|
|
|
<title>Procedural example</title>
|
2005-01-14 05:42:48 +00:00
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
$dbhandle = sqlite_open('mysqlitedb');
|
2005-09-09 21:42:13 +00:00
|
|
|
$query = sqlite_exec($dbhandle, "UPDATE users SET email='jDoe@example.com' WHERE username='jDoe'", $error);
|
2005-01-14 05:42:48 +00:00
|
|
|
if (!$query) {
|
2005-09-09 21:42:13 +00:00
|
|
|
exit("Error in query: '$error'");
|
2005-01-14 05:42:48 +00:00
|
|
|
} else {
|
|
|
|
echo 'Number of rows modified: ', sqlite_changes($dbhandle);
|
|
|
|
}
|
2005-09-09 21:42:13 +00:00
|
|
|
?>
|
|
|
|
]]>
|
2005-02-21 00:31:07 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title>Object-oriented example</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
2005-01-19 22:13:08 +00:00
|
|
|
$dbhandle = new SQLiteDatabase('mysqlitedb');
|
2005-09-09 21:42:13 +00:00
|
|
|
$query = $dbhandle->queryExec("UPDATE users SET email='jDoe@example.com' WHERE username='jDoe'", $error);
|
2005-01-14 05:42:48 +00:00
|
|
|
if (!$query) {
|
2005-09-09 21:42:13 +00:00
|
|
|
exit("Error in query: '$error'");
|
2005-01-14 05:42:48 +00:00
|
|
|
} else {
|
|
|
|
echo 'Number of rows modified: ', $dbhandle->changes();
|
|
|
|
}
|
2005-09-09 21:42:13 +00:00
|
|
|
?>
|
|
|
|
]]>
|
2005-01-14 05:42:48 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
2005-02-21 00:31:07 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
2004-05-13 14:36:08 +00:00
|
|
|
<para>
|
2005-02-21 00:31:07 +00:00
|
|
|
<simplelist>
|
|
|
|
<member><function>sqlite_query</function></member>
|
|
|
|
<member><function>sqlite_unbuffered_query</function></member>
|
|
|
|
<member><function>sqlite_array_query</function></member>
|
|
|
|
</simplelist>
|
2004-05-13 14:36:08 +00:00
|
|
|
</para>
|
2004-05-13 14:27:30 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
2005-02-21 00:31:07 +00:00
|
|
|
|
2004-05-13 14:27:30 +00:00
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
sgml-parent-document:nil
|
2009-09-25 07:04:39 +00:00
|
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
2004-05-13 14:27:30 +00:00
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|