class Pon::Adapter::Mysql

Defined in:

pon/adapter/mysql.cr

Constant Summary

BIND_TYPE = BindType::Question
LAST_VAL = "SELECT LAST_INSERT_ID()"
QUOTE = '`'
RawTypes = {"AUTO_Int32" => "INT NOT NULL AUTO_INCREMENT PRIMARY KEY", "AUTO_Int64" => "BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY", "Time::Span" => "TIME", "created_at" => "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", "updated_at" => "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"}
SETTING = "name = \"mysql\"\n\nurl = \"mysql://[email protected]:3306/mysql\"\ninit_pool_size = 1\nmax_pool_size = 5\n\n[query]\nshow_databases = \"SHOW DATABASES\"\nshow_tables = \"SHOW TABLES\""

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class Pon::Adapter::RDB

all(fields : Array(String), types, query_string = nil, **opts) all, count : Int32 count, databases : Array(String) databases, delete(key) : Nil
delete : Nil
delete
, exec(query : String, params = [] of String) exec, insert(fields, params) insert, lastval : Int64 lastval, one?(id, fields : Array(String), as types : Tuple) one?, query_all(*args, **options)
query_all(*args, **options, &)
query_all
, query_one?(*args, **options)
query_one?(*args, **options, &)
query_one?
, quote(*args, **options)
quote(*args, **options, &)
quote
, reset! : Nil reset!, scalar(*args, **options)
scalar(*args, **options, &)
scalar
, table_name : String table_name, tables : Array(String) tables, transaction(&) : Nil transaction, truncate : Nil truncate

Instance methods inherited from class Pon::Adapter

query_log(sql, group) query_log

Class methods inherited from class Pon::Adapter

build_database(setting) : DB::Database build_database, database(setting : Setting) : DB::Database database, databases databases, reset!(setting : Setting) : Nil
reset! : Nil
reset!
, settings settings

Constructor Detail

def self.new(klass, table_name : String, primary_name : String, setting : Pon::Setting | Nil = nil) #

[View source]

Class Method Detail

def self.escape(name : String) : String #

escapes the value by QUOTE


[View source]
def self.quote(name : String) : String #

ensures the value is quoted with idempotency returns the value itself when it already contains QUOTE

quote("foo")       # => "`foo`"
quote("`foo`")     # => "`foo`"
quote("`foo`.bar") # => "`foo`.bar"

[View source]
def self.raw_type?(key : String) #

converts the crystal class to database type of this adapter


[View source]
def self.setting #

[View source]

Instance Method Detail

def all(fields : Array(String), types, query_string = nil, **opts) #

[View source]
def all(fields : Array(String | Nil), types, query_string = nil, **opts) #

[View source]
def count : Int32 #

[View source]
def database : DB::Database #

#database abstracts unique connections and access to shared connections. Querying each time accessing without caching slightly degrades performance, but this mechanism is required when resetting shared connections.


[View source]
def databases : Array(String) #

ODBC


[View source]
def delete(key) : Nil #

[View source]
def delete : Nil #

[View source]
def exec(query : String, params = [] of String) #

NOTE all "?" appeared in query part will be replaced when params exist


[View source]
def insert(fields, params) #

[View source]
def lastval : Int64 #

[View source]
def one?(id, fields : Array(String), as types : Tuple) #

[View source]
def qp : String #

def qt : String #

def quote_field(name : String | Nil) : String #

[View source]
def reset! : Nil #

[View source]
def table_name : String #

def tables : Array(String) #

[View source]
def transaction(&) : Nil #

[View source]
def truncate : Nil #

[View source]
def update(fields, params) #

[View source]