lib/smart_session/mysql2.rb
# update session with given +data+.
# unlike the default implementation using ActiveRecord, updating of
# column `updated_at` will be done by the datbase itself
update session with given +data+.
unlike the default implementation using ActiveRecord, updating of
column `updated_at` will be done by the datbase itself
update session with given + data + . unlike the default implementation using ActiveRecord updating of column ` updated_at ` will be done by the datbase itself
def update_session(data)
      connection = self.class.session_connection
      if @id
        if SmartSession::SqlSession.locking_enabled?
          self.class.query("UPDATE #{SmartSession::SqlSession.table_name} SET `updated_at`=NOW(), `data`=#{self.class.quote(data)}, lock_version=lock_version+1 WHERE id=#{@id}")
          @lock_version += 1 
        else
          self.class.query("UPDATE #{SmartSession::SqlSession.table_name} SET `updated_at`=NOW(), `data`=#{self.class.quote(data)} WHERE id=#{@id}")
        end
      else
        self.class.query("INSERT INTO #{SmartSession::SqlSession.table_name} (`created_at`, `updated_at`, `session_id`, `data`) VALUES (NOW(), NOW(), '#{@session_id}', #{self.class.quote(data)})")
        @id = connection.last_id
        @lock_version = 0
      end
    end
def update_session ( data ) connection = self . class . session_connection if @id if SmartSession :: SqlSession . locking_enabled? self . class . query ( "UPDATE #{SmartSession::SqlSession.table_name} SET `updated_at`=NOW(), `data`=#{self.class.quote(data)}, lock_version=lock_version+1 WHERE id=#{@id}" ) @lock_version += 1 else self . class . query ( "UPDATE #{SmartSession::SqlSession.table_name} SET `updated_at`=NOW(), `data`=#{self.class.quote(data)} WHERE id=#{@id}" ) end else self . class . query ( "INSERT INTO #{SmartSession::SqlSession.table_name} (`created_at`, `updated_at`, `session_id`, `data`) VALUES (NOW(), NOW(), '#{@session_id}', #{self.class.quote(data)})" ) @id = connection . last_id @lock_version = 0 end end
update session with given +data+.
update session with given + data + .
# 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