Adapter for MySQL servers, built on the MySQLOO binary module (gmsv_mysqloo). It is
used when the database settings name the 'mysqloo' or 'mysql' adapter. Queries run
asynchronously unless the adapter is in sync mode, and queries with bind parameters are
sent as prepared statements. Tables are created with the InnoDB engine and the encoding
of the database settings ('utf8' by default), and the connection is pinged every 30
seconds to keep it alive. Unlike the other adapters, it does not run migrations in a
transaction.
Summary
Methods
Methods
ActiveRecord.Adapters.Mysqloo:append_query(query, _query_type, _queue)
shared packages/active_record/lib/adapters/mysqloo.lua:214Sets the table options (InnoDB engine and default charset) on a query before its SQL is built.
Parameters
- query ActiveRecord::Query
- _query_type String unused
- _queue Boolean optional, defaults to
nilunused
ActiveRecord.Adapters.Mysqloo:connect(config, on_connected)
shared packages/active_record/lib/adapters/mysqloo.lua:52Connects to a MySQL server through MySQLOO and pings it every 30 seconds to keep the connection alive. Calls #on_connection_failed if the connection fails.
Parameters
- config Map database settings: host, user, password, database, port (3306 if omitted), socket and flags
- on_connected Function optional, defaults to
nilcalled with the adapter once the connection is ready
ActiveRecord.Adapters.Mysqloo:create_column(query, column, _args, _obj, type, _def)
shared packages/active_record/lib/adapters/mysqloo.lua:225Makes the column the primary key of the table when a 'primary_key' column is created.
Parameters
- query ActiveRecord::Query query the column was added to
- column String column name
- _args Map unused
- _obj ActiveRecord::Query unused
- type String abstract column type
- _def String unused
ActiveRecord.Adapters.Mysqloo:disconnect()
shared packages/active_record/lib/adapters/mysqloo.lua:103Closes the MySQL connection, if there is one.
ActiveRecord.Adapters.Mysqloo:escape(str)
shared packages/active_record/lib/adapters/mysqloo.lua:114Escapes a string using the MySQL connection. Requires an established connection.
Parameters
- str String
Returns
- String
ActiveRecord.Adapters.Mysqloo:format_datetime(unix_time)
shared packages/active_record/lib/adapters/mysqloo.lua:37Converts a unix timestamp to the date-time form that MySQL takes in date-time columns.
Parameters
- unix_time Number
Returns
- String e.g. '2019-03-09 12:00:00', in UTC
Loads the 'mysqloo' binary module.
Checks whether the adapter talks to a MySQL database.
Returns
- Boolean always true
ActiveRecord.Adapters.Mysqloo:quote_name(str)
shared packages/active_record/lib/adapters/mysqloo.lua:122Quotes an identifier such as a table or column name with backticks, doubling the backticks in it.
Parameters
- str String
Returns
- String
ActiveRecord.Adapters.Mysqloo:raw_query(query, callback, query_type, bindings, error_callback)
shared packages/active_record/lib/adapters/mysqloo.lua:138Runs a raw SQL query on the MySQL server. In sync mode this blocks until the query is done; without a connection the query is put into the queue instead. A query that is given bindings is run as a prepared statement.
Parameters
- query String SQL to run
- callback Function optional, defaults to
nilcalled with the result rows (a List of row Maps), the query string, the time the query took in seconds and the bindings. For 'insert' queries the result is a single row with the id of the new row instead - query_type String optional, defaults to
nillowercase query type, e.g. 'insert' - bindings List optional, defaults to
nilvalues of the ? placeholders in the query. A query that is given bindings has to be a single statement - error_callback Function optional, defaults to
nilcalled with the error text if the query fails
Returns
- Any whatever the callback returns in sync mode, nothing otherwise