Module | ActiveRecord::ConnectionAdapters::DatabaseStatements
In: | lib/active_record/connection_adapters/abstract/database_statements.rb

### Methods

add_limit! add_limit_offset! add_lock! begin_db_transaction commit_db_transaction default_sequence_name delete delete_sql empty_insert_statement execute insert insert_fixture insert_sql reset_sequence! rollback_db_transaction sanitize_limit select select_all select_one select_rows select_value select_values transaction update update_sql

### Public Instance methods

add_limit!(sql, options)

Alias for `add_limit_offset!`.

add_limit_offset!(sql, options)

Appends `LIMIT` and `OFFSET` options to an SQL statement. This method modifies the `sql` parameter.

##### Examples

     add_limit_offset!('SELECT * FROM suppliers', {:limit => 10, :offset => 50})

generates

     SELECT * FROM suppliers LIMIT 10 OFFSET 50

add_lock!(sql, options)

Appends a locking clause to an SQL statement. This method modifies the `sql` parameter.

      # SELECT * FROM suppliers FOR UPDATE
      add_lock! 'SELECT * FROM suppliers', :lock => true
      add_lock! 'SELECT * FROM suppliers', :lock => ' FOR UPDATE'

begin_db_transaction()

Begins the transaction (and turns off auto-committing).

commit_db_transaction()

Commits the transaction (and turns on auto-committing).

default_sequence_name(table, column)
delete(sql, name = nil)

Executes the delete statement and returns the number of rows affected.

empty_insert_statement(table_name)
execute(sql, name = nil)

Executes the SQL statement in the context of this connection.

insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)

Returns the last auto-generated ID from the affected table.

insert_fixture(fixture, table_name)

Inserts the given fixture into the table. Overridden in adapters that require something beyond a simple insert (eg. Oracle).

reset_sequence!(table, column, sequence = nil)

Set the sequence to the max value of the table‘s column.

rollback_db_transaction()

Rolls back the transaction (and turns on auto-committing). Must be done if the transaction block raises an exception or returns false.

sanitize_limit(limit)
select_all(sql, name = nil)

Returns an array of record hashes with the column names as keys and column values as values.

select_one(sql, name = nil)

Returns a record hash with the column names as keys and column values as values.

select_rows(sql, name = nil)

Returns an array of arrays containing the field values. Order is the same as that returned by `columns`.

select_value(sql, name = nil)

Returns a single value from a record

select_values(sql, name = nil)

Returns an array of the values of the first column in a select:

      select_values("SELECT id FROM companies LIMIT 3") => [1,2,3]

transaction(start_db_transaction = true) {|| ...}

Wrap a block in a transaction. Returns result of block.

update(sql, name = nil)

Executes the update statement and returns the number of rows affected.

### Protected Instance methods

delete_sql(sql, name = nil)

Executes the delete statement and returns the number of rows affected.

insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)

Returns the last auto-generated ID from the affected table.

select(sql, name = nil)

Returns an array of record hashes with the column names as keys and column values as values.

update_sql(sql, name = nil)

Executes the update statement and returns the number of rows affected.

[Validate]