Class SQLite::ParsedStatement
In: lib/sqlite/parsed_statement.rb
Parent: Object

A ParsedStatement instance represents a tokenized version of an SQL statement. This makes it possible to do bind variable replacements multiple times, fairly efficiently.

Within the SQLite interfaces, this is used only by the Statement class. However, it could be reused by other SQL-reliant classes easily.

Methods

bind_param   bind_params   new   placeholders   sql   to_s   to_str  

Attributes

trailing  [R]  The text trailing the first recognized SQL statement that was parsed from the buffer given to this object. If there was no trailing SQL statement, this property will be the empty string.

Public Class methods

Create a new ParsedStatement. This will tokenize the given buffer. As an optimization, the tokenization is only performed if the string matches /[?:;]/, otherwise the string is used as-is.

Public Instance methods

Binds the given value to the placeholder indicated by param, which may be either a Fixnum or a String. If the indicated placeholder does not exist in the statement, this method does nothing.

Binds the given parameters to the placeholders in the statement. It does this by iterating over each argument and calling bind_param with the corresponding index (starting at 1). However, if any element is a hash, the hash is iterated through and bind_param called for each key/value pair. Hash‘s do not increment the index.

Returns an array of the placeholders known to this statement. This will either be empty (if the statement has no placeholders), or will contain numbers (indexes) and strings (names).

Returns the SQL that was given to this parsed statement when it was created, with bind placeholders intact.

Returns the statement as an SQL string, with all placeholders bound to their corresponding values.

to_str()

Alias for to_s

[Validate]