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

### Methods

all_rows all_rows bind bind bind_named_parameters bind_named_parameters bind_parameter_to bind_parameter_to bind_positional_parameters bind_positional_parameters check_parameter_count! check_parameter_count! close close column_count column_count each each execute execute is_column_rowid? is_column_rowid? new new next_row next_row open? open? param_position_of param_position_of remaining_sql remaining_sql reset! reset! reset_and_clear_bindings! reset_and_clear_bindings! reset_for_next_execute! reset_for_next_execute! result_fields result_fields result_meta result_meta rowid_column_names rowid_column_names sql sql using_rowid_column? using_rowid_column? write_blobs write_blobs

### Included Modules

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

### Attributes

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

### Public Class methods

new( db, sql )

Initialize a new statement on the database.

new( db, sql )

Initialize a new statement on the database.

rowid_column_names()

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

rowid_column_names()

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

### Public Instance methods

all_rows()

Return all rows from the statement as one array

all_rows()

Return all rows from the statement as one array

bind( *params )

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( *params )

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_named_parameters( params )

Bind parameters to the statement based upon named parameters

bind_named_parameters( params )

Bind parameters to the statement based upon named parameters

bind_parameter_to( position, value )

bind a single parameter to a particular position

bind_parameter_to( position, value )

bind a single parameter to a particular position

bind_positional_parameters( params )

Bind parameters to the statements based upon positions.

bind_positional_parameters( params )

Bind parameters to the statements based upon positions.

check_parameter_count!( num )

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

check_parameter_count!( num )

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

close()

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

close()

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

column_count()

return the number of columns in the result of this query

column_count()

return the number of columns in the result of this query

each() {|row| ...}

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.

each() {|row| ...}

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( *params ) {|row| ...}

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( *params ) {|row| ...}

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_column_rowid?( table_name, column_name )

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

is_column_rowid?( table_name, column_name )

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

next_row()

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

next_row()

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

open?()

is the statement open for business

open?()

is the statement open for business

param_position_of( name )

Find and cache the binding parameter indexes

param_position_of( name )

Find and cache the binding parameter indexes

remaining_sql()

Return any unsued SQL from the statement

remaining_sql()

Return any unsued SQL from the statement

reset!()

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!()

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_and_clear_bindings!()

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

reset_and_clear_bindings!()

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

reset_for_next_execute!()

reset the statment in preparation for executing it again

reset_for_next_execute!()

reset the statment in preparation for executing it again

result_fields()

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

result_fields()

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

result_meta()

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.

result_meta()

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.

sql()

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

sql()

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

using_rowid_column?()

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

using_rowid_column?()

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

write_blobs()

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

write_blobs()

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

[Validate]