mirror of
https://github.com/php/doc-ja.git
synced 2026-03-24 07:02:08 +01:00
214 lines
6.6 KiB
XML
214 lines
6.6 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 855bfee2f3db70d7dbb4c60c7c4a4efa567f1c60 Maintainer: takagi Status: ready -->
|
|
<!-- Credits: mumumu -->
|
|
|
|
<refentry xml:id="sqlite3stmt.bindvalue" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>SQLite3Stmt::bindValue</refname>
|
|
<refpurpose>パラメータの値を変数にバインドする</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis role="SQLite3Stmt">
|
|
<modifier>public</modifier> <type>bool</type><methodname>SQLite3Stmt::bindValue</methodname>
|
|
<methodparam><type class="union"><type>string</type><type>int</type></type><parameter>param</parameter></methodparam>
|
|
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>type</parameter><initializer><constant>SQLITE3_TEXT</constant></initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
パラメータの値を変数にバインドします。
|
|
</para>
|
|
<caution>
|
|
<para>
|
|
PHP 7.2.14 と 7.3.0 より前のバージョンでは、
|
|
ステートメントがいったん実行されると、
|
|
バインドされたパラメータの値を変えられるようにするために
|
|
<methodname>SQLite3Stmt::reset</methodname> を呼び出す必要がありました。
|
|
</para>
|
|
</caution>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>param</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
バインドされるべき文中の値を識別する
|
|
<type>string</type> (名前付きパラメータの場合) または
|
|
(位置パラメータの場合) <type>int</type>。
|
|
名前付きパラメータがコロン (<literal>:</literal>) や
|
|
アットマーク (<literal>@</literal>)
|
|
ではじまっていない場合、コロンが自動的に名前の前に付加されます。
|
|
位置パラメータは <literal>1</literal> から始まります。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>value</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
変数にバインドする値。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>type</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
バインドする値のデータ型。
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<constant>SQLITE3_INTEGER</constant>: 符号付き整数。
|
|
値の大きさに応じて 1, 2, 3, 4, 6, あるいは 8 バイトで格納されます。
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>SQLITE3_FLOAT</constant>: 浮動小数点数値。
|
|
8 バイトの IEEE 浮動小数点数値として格納されます。
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>SQLITE3_TEXT</constant>: テキスト文字列。
|
|
データベースのエンコーディング (UTF-8, UTF-16BE あるいは UTF-16-LE)
|
|
を用いて格納されます。
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>SQLITE3_BLOB</constant>: blob データ。
|
|
入力がそのままの形式で格納されます。
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>SQLITE3_NULL</constant>: NULL 値。
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
<para>
|
|
PHP 7.0.7 以降では、<parameter>type</parameter> が省略されると、
|
|
自動的に <parameter>value</parameter> の型から検出します:
|
|
<type>bool</type>
|
|
と <type>int</type> 型は <constant>SQLITE3_INTEGER</constant> として扱われ、
|
|
<type>float</type> は <constant>SQLITE3_FLOAT</constant>、
|
|
<type>null</type> は <constant>SQLITE3_NULL</constant>、
|
|
そして、これら以外は全て <constant>SQLITE3_TEXT</constant> として扱われます。
|
|
これより前のバージョンでは、<parameter>type</parameter> が省略されると、
|
|
デフォルトの型 <constant>SQLITE3_TEXT</constant> になっていました。
|
|
</para>
|
|
<note>
|
|
<para>
|
|
<parameter>value</parameter> が &null; の場合、
|
|
与えられた <parameter>type</parameter> に関わらず、
|
|
常に <constant>SQLITE3_NULL</constant> として扱われます。
|
|
</para>
|
|
</note>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
値を変数にバインドした場合に &true;、&return.falseforfailure;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>7.4.0</entry>
|
|
<entry>
|
|
<parameter>param</parameter> が、新たに <literal>@param</literal> 記法をサポートしました。
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>SQLite3Stmt::bindValue</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$db = new SQLite3(':memory:');
|
|
|
|
$db->exec('CREATE TABLE foo (id INTEGER, bar STRING)');
|
|
$db->exec("INSERT INTO foo (id, bar) VALUES (1, 'This is a test')");
|
|
|
|
$stmt = $db->prepare('SELECT bar FROM foo WHERE id=:id');
|
|
$stmt->bindValue(':id', 1, SQLITE3_INTEGER);
|
|
|
|
$result = $stmt->execute();
|
|
var_dump($result->fetchArray(SQLITE3_ASSOC));
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen role="php">
|
|
<![CDATA[
|
|
array(1) {
|
|
["bar"]=>
|
|
string(14) "This is a test"
|
|
}
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<simplelist>
|
|
<member><methodname>SQLite3Stmt::bindParam</methodname></member>
|
|
<member><methodname>SQLite3::prepare</methodname></member>
|
|
</simplelist>
|
|
</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
|
|
-->
|