lib/GDO/DB/Connection.rb
#
# Query the database.
# Rety once on error to reconnect.
#

Query the database.
Rety once on error to reconnect.
Query the database . Rety once on error to reconnect .
def query(query)
      begin
        retries ||= 0
        link = get_link
        @queries += 1 
        @@queries += 1
        t1 = Time.new
        result = link.query(query, cast:false)
        t2 = Time.new - t1
        @queries_time += t2
        @@queries_time += t2
        if @debug
          ::GDO::Core::Log.raw('queries', "#{@@queries} (#{t2}s): #{query}")
        end
        result
      rescue Mysql2::Error => e
        @link = nil
        retry if (retries += 1) <= 1
        ::GDO::Core::Log.exception(e) 
        raise ::GDO::DB::Exception.new(e.to_s).query(query) 
      rescue StandardError => e
        ::GDO::Core::Log.exception(e) 
        raise ::GDO::DB::Exception.new(e.to_s).query(query) 
      end
    end
def query ( query ) begin retries ||= 0 link = get_link @queries += 1 @@queries += 1 t1 = Time . new result = link . query ( query , cast : false ) t2 = Time . new - t1 @queries_time += t2 @@queries_time += t2 if @debug :: GDO :: Core :: Log . raw ( 'queries' , "#{@@queries} (#{t2}s): #{query}" ) end result rescue Mysql2 :: Error => e @link = nil retry if ( retries += 1 ) <= 1 :: GDO :: Core :: Log . exception ( e ) raise :: GDO :: DB :: Exception . new ( e . to_s ) . query ( query ) rescue StandardError => e :: GDO :: Core :: Log . exception ( e ) raise :: GDO :: DB :: Exception . new ( e . to_s ) . query ( query ) end end
Query the database.
Query the database .
# might connect
 # stats begin
 # Actual query
 # stats end
 # log
 # yay result
 # Workaround
 # turn to GDO::DB::Exception
 # log MySQL2 exception
 # turn to GDO::DB::Exception

query