<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Binds the value of a parameter to a statement variable</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="sqlite3stmt.bindparam.html">SQLite3Stmt::bindParam</a></div> <div class="next" style="text-align: right; float: right;"><a href="sqlite3stmt.clear.html">SQLite3Stmt::clear</a></div> <div class="up"><a href="class.sqlite3stmt.html">SQLite3Stmt</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="sqlite3stmt.bindvalue" class="refentry"> <div class="refnamediv"> <h1 class="refname">SQLite3Stmt::bindValue</h1> <p class="verinfo">(PHP 5 >= 5.3.0)</p><p class="refpurpose"><span class="refname">SQLite3Stmt::bindValue</span> — <span class="dc-title">Binds the value of a parameter to a statement variable</span></p> </div> <div class="refsect1 description" id="refsect1-sqlite3stmt.bindvalue-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><strong>SQLite3Stmt::bindValue</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$sql_param</code></span> , <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$type</code></span> ] )</div> <p class="para rdfs-comment"> Binds the value of a parameter to a statement variable. </p> </div> <div class="refsect1 parameters" id="refsect1-sqlite3stmt.bindvalue-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">sql_param</code></em></span> <dd> <p class="para"> An <span class="type"><a href="language.types.string.html" class="type string">string</a></span> identifying the statement variable to which the value should be bound. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">value</code></em></span> <dd> <p class="para"> The value to bind to a statement variable. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">type</code></em></span> <dd> <p class="para"> The data type of the value to bind. <ul class="itemizedlist"> <li class="listitem"> <p class="para"> <em>SQLITE3_INTEGER</em>: The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value. </p> </li> <li class="listitem"> <p class="para"> <em>SQLITE3_FLOAT</em>: The value is a floating point value, stored as an 8-byte IEEE floating point number. </p> </li> <li class="listitem"> <p class="para"> <em>SQLITE3_TEXT</em>: The value is a text string, stored using the database encoding (UTF-8, UTF-16BE or UTF-16-LE). </p> </li> <li class="listitem"> <p class="para"> <em>SQLITE3_BLOB</em>: The value is a blob of data, stored exactly as it was input. </p> </li> <li class="listitem"> <p class="para"> <em>SQLITE3_NULL</em>: The value is a NULL value. </p> </li> </ul> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-sqlite3stmt.bindvalue-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>TRUE</code></strong> if the value is bound to the statement variable, <strong><code>FALSE</code></strong> on failure. </p> </div> <div class="refsect1 examples" id="refsect1-sqlite3stmt.bindvalue-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-2166"> <p><strong>Example #1 <span class="function"><strong>SQLite3Stmt::bindValue()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />unlink</span><span style="color: #007700">(</span><span style="color: #DD0000">'mysqlitedb.db'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$db </span><span style="color: #007700">= new </span><span style="color: #0000BB">SQLite3</span><span style="color: #007700">(</span><span style="color: #DD0000">'mysqlitedb.db'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$db</span><span style="color: #007700">-></span><span style="color: #0000BB">exec</span><span style="color: #007700">(</span><span style="color: #DD0000">'CREATE TABLE foo (id INTEGER, bar STRING)'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$db</span><span style="color: #007700">-></span><span style="color: #0000BB">exec</span><span style="color: #007700">(</span><span style="color: #DD0000">"INSERT INTO foo (id, bar) VALUES (1, 'This is a test')"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$stmt </span><span style="color: #007700">= </span><span style="color: #0000BB">$db</span><span style="color: #007700">-></span><span style="color: #0000BB">prepare</span><span style="color: #007700">(</span><span style="color: #DD0000">'SELECT bar FROM foo WHERE id=:id'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$stmt</span><span style="color: #007700">-></span><span style="color: #0000BB">bindValue</span><span style="color: #007700">(</span><span style="color: #DD0000">':id'</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">SQLITE3_INTEGER</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">$stmt</span><span style="color: #007700">-></span><span style="color: #0000BB">execute</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">-></span><span style="color: #0000BB">fetchArray</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="sqlite3stmt.bindparam.html">SQLite3Stmt::bindParam</a></div> <div class="next" style="text-align: right; float: right;"><a href="sqlite3stmt.clear.html">SQLite3Stmt::clear</a></div> <div class="up"><a href="class.sqlite3stmt.html">SQLite3Stmt</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>