Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ol> <li><p>There are; it's the <a href="http://sqlite.org/c3ref/bind_parameter_index.html" rel="nofollow"><code>sqlite3_bind_parameter_index()</code></a> function you mentioned that you use to turn a parameter name into an index, which you can then use with the <a href="http://sqlite.org/c3ref/bind_blob.html" rel="nofollow"><code>sqlite3_bind_*()</code></a> functions. However, there's no <code>sqlite3_bind_*_by_name()</code> function or anything like that. This is to help prevent API bloat. The popular <a href="http://github.com/ccgus/fmdb" rel="nofollow">Flying Meat Database sqlite wrapper</a> has support for named parameters in one of its branches, if you're interested in seeing how it's used.</p> <p>If you think about what it would take to implement full named parameter binding methods, consider the current list of <code>bind</code> functions:</p> <pre><code>int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); int sqlite3_bind_double(sqlite3_stmt*, int, double); int sqlite3_bind_int(sqlite3_stmt*, int, int); int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); int sqlite3_bind_null(sqlite3_stmt*, int); int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*)); int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); </code></pre> <p>If we wanted to add explicit support for named parameters, that list would double in length to include:</p> <pre><code>int sqlite3_bind_name_blob(sqlite3_stmt*, const char*, const void*, int n, void(*)(void*)); int sqlite3_bind_name_double(sqlite3_stmt*, const char*, double); int sqlite3_bind_name_int(sqlite3_stmt*, const char*, int); int sqlite3_bind_name_int64(sqlite3_stmt*, const char*, sqlite3_int64); int sqlite3_bind_name_null(sqlite3_stmt*, const char*); int sqlite3_bind_name_text(sqlite3_stmt*, const char*, const char*, int n, void(*)(void*)); int sqlite3_bind_name_text16(sqlite3_stmt*, const char*, const void*, int, void(*)(void*)); int sqlite3_bind_name_value(sqlite3_stmt*, const char*, const sqlite3_value*); int sqlite3_bind_name_zeroblob(sqlite3_stmt*, const char*, int n); </code></pre> <p>Twice as many functions means a lot more time spent maintaining API, ensuring backwards-compatibility, etc etc. However, by simply introducing the <code>sqlite3_bind_parameter_index()</code>, they were able to add complete support for named parameters with only a <em>single</em> function. This means that if they ever decide to support new bind types (maybe <code>sqlite3_bind_int128</code>?), they only have to add a single function, and not two.</p></li> <li><p>As for why no one seems to use it... I can't give any sort of definitive answer with conducting a survey. My <em>guess</em> would be that it's a bit more natural to refer to parameters sequentially, in which case named parameters aren't that useful. Named parameters only seem to be useful if you need to refer to parameters out of order.</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload