Sha256: 63430e5e5997d02226a698f1cef642ce35eb87d6e0b7fc41a4c3de402b693d95

Contents?: true

Size: 1.33 KB

Versions: 18

Compression:

Stored size: 1.33 KB

Contents

require File.expand_path("../example_setup", __FILE__)
require "github/sql"

################################# Class Style ##################################
sql = GitHub::SQL.run <<-SQL, key: "foo", value: "bar"
  INSERT INTO example_key_values (`key`, `value`) VALUES (:key, :value)
SQL
p sql.last_insert_id
# 1

p GitHub::SQL.value <<-SQL, key: "foo"
  SELECT value FROM example_key_values WHERE `key` = :key
SQL
# "bar"

sql = GitHub::SQL.run <<-SQL, key: "foo", value: "new value"
  UPDATE example_key_values SET value = :value WHERE `key` = :key
SQL
p sql.affected_rows
# 1

sql = GitHub::SQL.run <<-SQL, key: "foo"
  DELETE FROM example_key_values WHERE `key` = :key
SQL
p sql.affected_rows
# 1


################################ Instance Style ################################
sql = GitHub::SQL.new <<-SQL, key: "foo", value: "bar"
  INSERT INTO example_key_values (`key`, `value`) VALUES (:key, :value)
SQL
sql.run
p sql.last_insert_id
# 2

sql = GitHub::SQL.new <<-SQL, key: "foo"
  SELECT value FROM example_key_values WHERE `key` = :key
SQL
p sql.value
# "bar"

sql = GitHub::SQL.new <<-SQL, key: "foo", value: "new value"
  UPDATE example_key_values SET value = :value WHERE `key` = :key
SQL
sql.run
p sql.affected_rows
# 1

sql = GitHub::SQL.new <<-SQL, key: "foo"
  DELETE FROM example_key_values WHERE `key` = :key
SQL
sql.run
p sql.affected_rows
# 1

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
github-ds-0.5.4 examples/sql.rb
github-ds-0.5.3 examples/sql.rb
github-ds-0.5.2 examples/sql.rb
github-ds-0.5.0 examples/sql.rb
github-ds-0.4.0 examples/sql.rb
github-ds-0.3.0 examples/sql.rb
github-ds-0.2.11 examples/sql.rb
github-ds-0.2.10 examples/sql.rb
github-ds-0.2.9 examples/sql.rb
github-ds-0.2.8 examples/sql.rb
github-ds-0.2.7 examples/sql.rb
github-ds-0.2.6 examples/sql.rb
github-ds-0.2.5 examples/sql.rb
github-ds-0.2.4 examples/sql.rb
github-ds-0.2.3 examples/sql.rb
github-ds-0.2.2 examples/sql.rb
github-ds-0.2.1 examples/sql.rb
github-ds-0.2.0 examples/sql.rb