<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.sqlite3stmt.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'sqlite3stmt.getsql.php',
    1 => 'SQLite3Stmt::getSQL',
    2 => 'Get the SQL of the statement',
  ),
  'up' => 
  array (
    0 => 'class.sqlite3stmt.php',
    1 => 'SQLite3Stmt',
  ),
  'prev' => 
  array (
    0 => 'sqlite3stmt.execute.php',
    1 => 'SQLite3Stmt::execute',
  ),
  'next' => 
  array (
    0 => 'sqlite3stmt.paramcount.php',
    1 => 'SQLite3Stmt::paramCount',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/sqlite3/sqlite3stmt/getsql.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="sqlite3stmt.getsql" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SQLite3Stmt::getSQL</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.4.0, PHP 8)</p><p class="refpurpose"><span class="refname">SQLite3Stmt::getSQL</span> &mdash; <span class="dc-title">Get the SQL of the statement</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-sqlite3stmt.getsql-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>SQLite3Stmt::getSQL</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$expand</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   Retrieves the SQL of the prepared statement. If <code class="parameter">expand</code>
   is <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>, the unmodified SQL is retrieved. If <code class="parameter">expand</code>
   is <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, all query parameters are replaced with their bound values, or with
   an SQL <code class="literal">NULL</code>, if not already bound.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-sqlite3stmt.getsql-parameters">
  <h3 class="title">Parameters</h3>
  <dl>
   
    <dt><code class="parameter">expand</code></dt>
    <dd>
     <p class="para">
      Whether to retrieve the expanded SQL. Passing <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> is only supported as
      of libsqlite 3.14.
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-sqlite3stmt.getsql-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the SQL of the prepared statement,  or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> on failure.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-sqlite3stmt.getsql-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="para">
   If <code class="parameter">expand</code> is <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, but the libsqlite version is less
   than 3.14, an error of level <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> or an <span class="classname"><a href="class.exception.php" class="classname">Exception</a></span>
   is issued, according to <span class="methodname"><a href="sqlite3.enableexceptions.php" class="methodname">SQLite3::enableExceptions()</a></span>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-sqlite3stmt.getsql-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="sqlite3stmt.getsql.example.expanded">
   <p><strong>Example #1 Inspecting the expanded SQL</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$db </span><span style="color: #007700">= new </span><span style="color: #0000BB">SQLite3</span><span style="color: #007700">(</span><span style="color: #DD0000">':memory:'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$stmt </span><span style="color: #007700">= </span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">prepare</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT :a, ?, :c"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$stmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">bindValue</span><span style="color: #007700">(</span><span style="color: #DD0000">':a'</span><span style="color: #007700">, </span><span style="color: #DD0000">'foo'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$answer </span><span style="color: #007700">= </span><span style="color: #0000BB">42</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$stmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">bindParam</span><span style="color: #007700">(</span><span style="color: #0000BB">2</span><span style="color: #007700">, </span><span style="color: #0000BB">$answer</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getSQL</span><span style="color: #007700">(</span><span style="color: #0000BB">true</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>The above example will output
something similar to:</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">string(24) &quot;SELECT &#039;foo&#039;, &#039;42&#039;, NULL&quot;</pre>
</div>
   </div>
  </div>
 </div>


</div><?php manual_footer($setup); ?>