     
 }
 
+///
+/// Statements are used to update the database, query data, and read results. Statements are like methods and can accept
+/// parameters. This makes it easy to escape SQL values, as well as reuse statements for optimal performance.
+///
 public class Statement : NSObject {
     
     private weak var database : Database?

    // -----------------------------------------------------------------------------------------------------------------
    // MARK:  Query
    
    public func query(sqlString:String, error:NSErrorPointer) -> Statement? {
        let sqliteStatement = prepareSqliteStatement(sqlString, error:error)
        if sqliteStatement == nil {
            return nil
        }
        
        var statement = Statement(database: self, sqliteStatement: sqliteStatement)
        statements.append(WeakStatement(statement))
        return statement
    }
    
    public func query(sqlString:String, parameters:[Bindable?]?, error:NSErrorPointer) -> Statement? {
        if let statement = query(sqlString, error:error) {
            if parameters?.count > 0 {
                var boundSuccessfully = statement.bind(parameters!, error:error)
                if !boundSuccessfully {

    // -----------------------------------------------------------------------------------------------------------------
    // MARK:  Transactions
    
    /// Result type used to commit or rollback transactions and savepoints.
    public enum TransactionResult {
        case Commit
        case Rollback
        case Failed(NSError)
    }

    /// Begins a database transaction by executing a BEGIN TRANSACTION statement. Transactions cannot be nested. If
    /// nested operations are needed, consider using savepoints instead.
    ///
    /// :returns: `true` if the transaction began, `false` otherwise.
    public func beginTransaction(error:NSErrorPointer = nil) -> Bool {
        return execute("BEGIN TRANSACTION", error: error)
    }

    /// Ends the current transaction and discards changes since the transaction began. All savepoints are also rolled
    /// back. See sqlite docs for details on transaction support.
    ///
    /// :returns: `true` if the transaction was rolled back, `false` otherwise.
    public func rollback(error:NSErrorPointer = nil) -> Bool {
        return execute("ROLLBACK", error: error)
    }

    /// Commits the current transaction and persists changes since the transaction began. All savepoints are also
    /// committed. See sqlite docs for details on transaction support.
    ///
    /// :returns: `true` if the transaction was committed, `false` otherwise.
    public func commit(error:NSErrorPointer = nil) -> Bool {
        return execute("COMMIT", error: error)
    }

    ///
    /// Begins a transaction, invokes the provided closure, and uses its result to determine how to terminate the
    /// transaction. Using this method is more concise than creating and managing the transaction yourself. For example:
    /// 
    ///     let result = db.transaction {
    ///         var error : NSError?
    ///         if let rowId = $0.insertInto("people", values:["name":"Agnes Pigott"], error:&error) {
    ///             return .Failed(error)
    ///         }
    ///
    ///         // more SQL statements...
    ///
    ///         return .Commit
    ///     }
    ///
    /// :param: block   The operation to perform within the transaction. It should not close the transaction itself, but
    ///                 instead return a TransactionResult.
    /// :returns:       The result of the transaction. This should nearly always be the same value returned by the
    ///                 block, except when the BEGIN, ROLLBACK, or COMMIT statements fail.
    ///
    public func transaction(block:(db:Database)->TransactionResult) -> TransactionResult {
        var localError : NSError?
        var didBegin = beginTransaction(error: &localError)
