class Pon::Adapter::Mysql
- Pon::Adapter::Mysql
- Pon::Adapter::RDB
- Pon::Adapter
- Reference
- Object
Defined in:
pon/adapter/mysql.crConstant 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
-
.escape(name : String) : String
escapes the value by
QUOTE
-
.quote(name : String) : String
ensures the value is quoted with idempotency returns the value itself when it already contains
QUOTE
crystal quote("foo") # => "`foo`" quote("`foo`") # => "`foo`" quote("`foo`.bar") # => "`foo`.bar"
-
.raw_type?(key : String)
converts the crystal class to database type of this adapter
- .setting
Instance Method Summary
- #all(fields : Array(String), types, query_string = nil, **opts)
- #all(fields : Array(String | Nil), types, query_string = nil, **opts)
- #count : Int32
-
#database : DB::Database
#database
abstracts unique connections and access to shared connections. - #databases : Array(String)
- #delete(key) : Nil
- #delete : Nil
-
#exec(query : String, params = [] of String)
NOTE all "?" appeared in query part will be replaced when params exist
- #insert(fields, params)
- #lastval : Int64
- #one?(id, fields : Array(String), as types : Tuple)
- #qp : String
- #qt : String
- #quote_field(name : String | Nil) : String
- #reset! : Nil
- #table_name : String
- #tables : Array(String)
- #transaction(&) : Nil
- #truncate : Nil
- #update(fields, params)
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) : Nildelete : 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) : Nilreset! : Nil reset!, settings settings
Constructor Detail
Class Method Detail
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"
Instance Method Detail
#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.
NOTE all "?" appeared in query part will be replaced when params exist