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 execute insert reset_sequence! rollback_db_transaction select select_all select_one select_value select_values transaction update

### Public Instance methods

add_limit!(sql, options)

Alias for add_limit_offset!.

add_limit_offset!(sql, options)

Appends `LIMIT` and `OFFSET` options to a 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 a SQL statement. *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.

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.

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.

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_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

select(sql, name = nil)

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

[Validate]