Class Amalgalite::Statement
In: lib/amalgalite/statement.rb
lib/amalgalite/statement.rb
Parent: Object

Methods

Included Modules

::Amalgalite::SQLite3::Constants ::Amalgalite::SQLite3::Constants

Attributes

api  [R] 
api  [R] 
db  [R] 
db  [R] 

Public Class methods

Initialize a new statement on the database.

Initialize a new statement on the database.

special column names that indicate that indicate the column is a rowid

special column names that indicate that indicate the column is a rowid

Public Instance methods

Return all rows from the statement as one array

Return all rows from the statement as one array

Bind parameters to the sql statement.

Bindings in SQLite can have a number of formats:

  ?
  ?num
  :var
  @var
  $var

Where ‘num’ is an Integer and ‘var‘is an alphanumerical variable. They may exist in the SQL for which this Statement was created.

Amalgalite binds parameters to these variables in the following manner:

If bind is passed in an Array, either as +bind( "foo", "bar", "baz")+ or as bind( ["foo", "bar", "baz"] ) then each of the params is assumed to be positionally bound to the statement( ?, ?num ).

If bind is passed a Hash, either as +bind( :foo => 1, :bar => ‘sqlite’ )+ or as bind( { :foo => 1, ‘bar’ => ‘sqlite’ }) then it is assumed that each parameter should be bound as a named parameter (:var, @var, $var).

If bind is not passed any parameters, or nil, then nothing happens.

Bind parameters to the sql statement.

Bindings in SQLite can have a number of formats:

  ?
  ?num
  :var
  @var
  $var

Where ‘num’ is an Integer and ‘var‘is an alphanumerical variable. They may exist in the SQL for which this Statement was created.

Amalgalite binds parameters to these variables in the following manner:

If bind is passed in an Array, either as +bind( "foo", "bar", "baz")+ or as bind( ["foo", "bar", "baz"] ) then each of the params is assumed to be positionally bound to the statement( ?, ?num ).

If bind is passed a Hash, either as +bind( :foo => 1, :bar => ‘sqlite’ )+ or as bind( { :foo => 1, ‘bar’ => ‘sqlite’ }) then it is assumed that each parameter should be bound as a named parameter (:var, @var, $var).

If bind is not passed any parameters, or nil, then nothing happens.

Bind parameters to the statement based upon named parameters

Bind parameters to the statement based upon named parameters

bind a single parameter to a particular position

bind a single parameter to a particular position

Bind parameters to the statements based upon positions.

Bind parameters to the statements based upon positions.

Check and make sure that the number of parameters aligns with the number that sqlite expects

Check and make sure that the number of parameters aligns with the number that sqlite expects

Close the statement. The statement is no longer valid for use after it has been closed.

Close the statement. The statement is no longer valid for use after it has been closed.

return the number of columns in the result of this query

return the number of columns in the result of this query

Iterate over the results of the statement returning each row of results as a hash by column_name. The column names are the value after an ‘AS’ in the query or default chosen by sqlite.

Iterate over the results of the statement returning each row of results as a hash by column_name. The column names are the value after an ‘AS’ in the query or default chosen by sqlite.

Execute the statement with the given parameters

If a block is given, then yield each returned row to the block. If no block is given then return all rows from the result. No matter what the prepared statement should be reset before returning the final time.

Execute the statement with the given parameters

If a block is given, then yield each returned row to the block. If no block is given then return all rows from the result. No matter what the prepared statement should be reset before returning the final time.

is the column indicated by the Column a ‘rowid’ column

is the column indicated by the Column a ‘rowid’ column

Return the next row of data, with type conversion as indicated by the Database#type_map

Return the next row of data, with type conversion as indicated by the Database#type_map

is the statement open for business

is the statement open for business

Find and cache the binding parameter indexes

Find and cache the binding parameter indexes

Return any unsued SQL from the statement

Return any unsued SQL from the statement

reset the Statement back to it state right after the constructor returned, except if any variables have been bound to parameters, those are still bound.

reset the Statement back to it state right after the constructor returned, except if any variables have been bound to parameters, those are still bound.

reset the Statement back to it state right after the constructor returned, AND clear all parameter bindings.

reset the Statement back to it state right after the constructor returned, AND clear all parameter bindings.

reset the statment in preparation for executing it again

reset the statment in preparation for executing it again

Return the array of field names for the result set, the field names are all strings

Return the array of field names for the result set, the field names are all strings

Inspect the statement and gather all the meta information about the results, include the name of the column result column and the origin column. The origin column is the original database.table.column the value comes from.

The full meta information from the origin column is also obtained for help in doing type conversion.

As iteration over the row meta informatio happens, record if the special "ROWID", "OID", or "ROWID" column is encountered. If that column is encountered then we make note of it.

Inspect the statement and gather all the meta information about the results, include the name of the column result column and the origin column. The origin column is the original database.table.column the value comes from.

The full meta information from the origin column is also obtained for help in doing type conversion.

As iteration over the row meta informatio happens, record if the special "ROWID", "OID", or "ROWID" column is encountered. If that column is encountered then we make note of it.

return the raw sql that was originally used to prepare the statement

return the raw sql that was originally used to prepare the statement

Is the special column "ROWID", "OID", or "ROWID" used?

Is the special column "ROWID", "OID", or "ROWID" used?

Write any blobs that have been bound to parameters to the database. This assumes that the blobs go into the last inserted row

Write any blobs that have been bound to parameters to the database. This assumes that the blobs go into the last inserted row

[Validate]