php-doc-en/reference/sqlite3/sqlite3stmt/getsql.xml
Christoph Michael Becker 0c2deb3a85 Document SQLite3Stmt::getSQL() (as of PHP 7.4.0)
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@346355 c90b9560-bf6c-de11-be94-00142212c4b1
2018-12-16 11:56:12 +00:00

101 lines
2.8 KiB
XML

<?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>
<modifier>public</modifier> <type>string</type><methodname>SQLite3Stmt::getSQL</methodname>
<methodparam choice="opt"><type>bool</type><parameter>expanded</parameter><initializer>&false;</initializer></methodparam>
</methodsynopsis>
<para>
Retrieves the SQL of the prepared statement. If <parameter>expanded</parameter>
is &false;, the unmodified SQL is retrieved. If <parameter>expanded</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>expanded</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>expanded</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
-->