mozIStorageStatementParams

  • Revision slug: mozIStorageStatementParams
  • Revision title: mozIStorageStatementParams
  • Revision id: 131800
  • Created:
  • Creator: sdwilsh
  • Is current revision? No
  • Comment 186 words added, 52 words removed; page display name changed to 'mozIStorageStatementParams'

Revision Content

This interface has no defined properties, but has properties based on the named parameters found in the SQL from the statement it was accessed off of.  For example, say you create a statement like so:

var statement = dbConn.createStatement("SELECT * FROM table_name WHERE id = :item_id");

This object would have one property, item_id, that you can use to bind a value to that named parameter like so:

statement.params.item_id = 2;

For more details on why you should bind parameters as opposed to hard-coding them into your statement, please see the overview document about binding parameters.

Enumeration of Properties

{{ fx_minversion_header("3") }} You can also enumerate all the properties on this object with a for..in enumeration:

// valuesToBind is an object that contains key-value pairs
// to bind to the statement before executing it.
for (let param in statement.params)
  statement.params[param] = valuesToBind[param];

See also

  • Storage
  • {{ interface("mozIStorageStatement") }}

Revision Source

<p>This interface has no defined properties, but has properties based on the named parameters found in the SQL from the statement it was accessed off of.  For example, say you create a statement like so:</p>
<pre class="brush: js">var statement = dbConn.createStatement("SELECT * FROM table_name WHERE id = :item_id");
</pre>
<p>This object would have one property, item_id, that you can use to bind a value to that named parameter like so:</p>
<pre class="brush: js">statement.params.item_id = 2;
</pre>
<p>For more details on why you should bind parameters as opposed to hard-coding them into your statement, please see the <a class="internal" href="/En/Storage#Binding_Parameters" title="En/Storage">overview document about binding parameters</a>.</p>
<h2>Enumeration of Properties</h2>
<p>{{ fx_minversion_header("3") }} You can also enumerate all the properties on this object with a <code><a class="internal" href="/En/Core%20JavaScript%201.5%20Reference/Statements/For...in" title="En/Core JavaScript 1.5 Reference/Statements/For...in">for..in</a></code> enumeration:</p>
<pre class="brush: js">// valuesToBind is an object that contains key-value pairs
// to bind to the statement before executing it.
for (let param in statement.params)
  statement.params[param] = valuesToBind[param];
</pre>
<h3 name="See_also">See also</h3>
<ul> <li><a href="/en/Storage" title="en/Storage">Storage</a></li> <li>{{ interface("mozIStorageStatement") }}</li>
</ul>
Revert to this revision