lib/smart_session/sqlite.rb
# update session with given +data+.
# unlike the default implementation using ActiveRecord, updating of
# column `updated_at` will be done by the database itself
update session with given +data+.
unlike the default implementation using ActiveRecord, updating of
column `updated_at` will be done by the database itself
update session with given + data + . unlike the default implementation using ActiveRecord updating of column ` updated_at ` will be done by the database itself
def update_session(data)
      connection = SmartSession::SqlSession.connection.instance_variable_get(:@connection) 
      if @id
        if SqlSession.locking_enabled?
          @lock_version += 1 
          self.class.query("UPDATE #{SmartSession::SqlSession.table_name} SET `updated_at`=datetime('now'), `data`='#{SQLite3::Database.quote(data)}', lock_version=lock_version+1 WHERE id=#{@id}")
        else
          self.class.query("UPDATE #{SmartSession::SqlSession.table_name} SET `updated_at`=datetime('now'), `data`='#{SQLite3::Database.quote(data)}' WHERE id=#{@id}")
        end
      else
        self.class.query("INSERT INTO #{SmartSession::SqlSession.table_name} ('id', `created_at`, `updated_at`, `session_id`, `data`) VALUES (NULL, datetime('now'), datetime('now'), '#{@session_id}', '#{SQLite3::Database.quote(data)}')")
        @id = connection.last_insert_row_id()
        @lock_version = 0
      end
    end
def update_session ( data ) connection = SmartSession :: SqlSession . connection . instance_variable_get ( :@connection ) if @id if SqlSession . locking_enabled? @lock_version += 1 self . class . query ( "UPDATE #{SmartSession::SqlSession.table_name} SET `updated_at`=datetime('now'), `data`='#{SQLite3::Database.quote(data)}', lock_version=lock_version+1 WHERE id=#{@id}" ) else self . class . query ( "UPDATE #{SmartSession::SqlSession.table_name} SET `updated_at`=datetime('now'), `data`='#{SQLite3::Database.quote(data)}' WHERE id=#{@id}" ) end else self . class . query ( "INSERT INTO #{SmartSession::SqlSession.table_name} ('id', `created_at`, `updated_at`, `session_id`, `data`) VALUES (NULL, datetime('now'), datetime('now'), '#{@session_id}', '#{SQLite3::Database.quote(data)}')" ) @id = connection . last_insert_row_id ( ) @lock_version = 0 end end
update session with given +data+.
update session with given + data + .
#self.class.session_connection # if @id is not nil, this is a session already stored in the database # update the relevant field using @id as key #if we are here then we hold a lock on the table - we know our version is up to date # if @id is nil, we need to create a new session in the database # and set @id to the primary key of the inserted record
data