downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

SQLite3Stmt::clear> <SQLite3Stmt::bindParam
[edit] Last updated: Fri, 25 May 2012

view this page in

SQLite3Stmt::bindValue

(PHP 5 >= 5.3.0)

SQLite3Stmt::bindValueパラメータの値を変数にバインドする

説明

public bool SQLite3Stmt::bindValue ( string $sql_param , mixed $value [, int $type ] )

パラメータの値を変数にバインドします。

パラメータ

sql_param

値をどの変数にバインドするかを表す文字列。

value

変数にバインドする値。

type

バインドする値のデータ型。

  • SQLITE3_INTEGER: 符号付き整数。 値の大きさに応じて 1, 2, 3, 4, 6, あるいは 8 バイトで格納されます。

  • SQLITE3_FLOAT: 浮動小数点数値。 8 バイトの IEEE 浮動小数点数値として格納されます。

  • SQLITE3_TEXT: テキスト文字列。 データベースのエンコーディング (UTF-8, UTF-16BE あるいは UTF-16-LE) を用いて格納されます。

  • SQLITE3_BLOB: blob データ。 入力がそのままの形式で格納されます。

  • SQLITE3_NULL: NULL 値。

返り値

値を変数にバインドした場合に TRUE、 失敗した場合に FALSE を返します。

例1 SQLite3Stmt::bindValue() の例

<?php
unlink
('mysqlitedb.db');
$db = new SQLite3('mysqlitedb.db');

$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'1SQLITE3_INTEGER);

$result $stmt->execute();
var_dump($result->fetchArray());
?>



add a note add a note User Contributed Notes SQLite3Stmt::bindValue
zeebinz at gmail dot com 23-Jul-2010 07:54
Note that this also works with positional placeholders using the '?' token:

<?php

$stmt
= $db->prepare('SELECT * FROM mytable WHERE foo = ? AND bar = ?');
$stmt->bindValue(1, 'somestring', SQLITE3_TEXT);
$stmt->bindValue(2, 42, SQLITE3_INTEGER);

?>

Positional numbering starts at 1.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites