<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="sqlite3stmt.getsql" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>SQLite3Stmt::getSQL</refname>
  <refpurpose>Get the SQL of the statement</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis role="SQLite3Stmt">
   <modifier>public</modifier> <type class="union"><type>string</type><type>false</type></type><methodname>SQLite3Stmt::getSQL</methodname>
   <methodparam choice="opt"><type>bool</type><parameter>expand</parameter><initializer>&false;</initializer></methodparam>
  </methodsynopsis>
  <para>
   Retrieves the SQL of the prepared statement. If <parameter>expand</parameter>
   is &false;, the unmodified SQL is retrieved. If <parameter>expand</parameter>
   is &true;, all query parameters are replaced with their bound values, or with
   an SQL <literal>NULL</literal>, if not already bound.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <variablelist>
   <varlistentry>
    <term><parameter>expand</parameter></term>
    <listitem>
     <para>
      Whether to retrieve the expanded SQL. Passing &true; is only supported as
      of libsqlite 3.14.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   Returns the SQL of the prepared statement, &return.falseforfailure;.
  </para>
 </refsect1>

 <refsect1 role="errors">
  &reftitle.errors;
  <para>
   If <parameter>expand</parameter> is &true;, but the libsqlite version is less
   than 3.14, an error of level <constant>E_WARNING</constant> or an <classname>Exception</classname>
   is issued, according to <methodname>SQLite3::enableExceptions</methodname>.
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <example xml:id="sqlite3stmt.getsql.example.expanded">
   <title>Inspecting the expanded SQL</title>
   <programlisting role="php">
<![CDATA[
<?php
$db = new SQLite3(':memory:');
$stmt = $db->prepare("SELECT :a, ?, :c");
$stmt->bindValue(':a', 'foo');
$answer = 42;
$stmt->bindParam(2, $answer);
var_dump($stmt->getSQL(true));
?>
]]>
   </programlisting>
   &example.outputs.similar;
   <screen>
<![CDATA[
string(24) "SELECT 'foo', '42', NULL"
]]>
   </screen>
  </example>
 </refsect1>

</refentry>
<!-- 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
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
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
-->
