array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'sqlite3stmt.getsql.php', 1 => 'SQLite3Stmt::getSQL', ), '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' => 'ja', 'path' => 'reference/sqlite3/sqlite3stmt/getsql.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 7 >= 7.4.0, PHP 8)
SQLite3Stmt::getSQL — ステートメントのSQLを取得する
プリペアドステートメントのSQLを取得します。
expand
が false
の場合、
変更されていないSQLを取得します。
expand
が true
の場合、
全てのクエリパラメータがバインド済みの値で、
何もバインドされていない場合は NULL
で置き換えられます。
expand
展開済みのSQLを取得するかどうか。
true
を渡すのは、libsqlite 3.14 以降でのみサポートされています。
プリペアドステートメントのSQLを返します。
失敗した場合に false
を返します
expand
を true
に指定したが、libsqlite のバージョンが
3.14 より前の場合、
SQLite3::enableExceptions() に応じて、
E_WARNING
レベルの警告または Exception が発生します。
例1 展開済みのSQLを調べる
<?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));
?>
上の例の出力は、 たとえば以下のようになります。
string(24) "SELECT 'foo', '42', NULL"