OHMySQLStoreCoordinator

Objective-C

@interface OHMySQLStoreCoordinator : NSObject

/// Nonnull after connection with DB. 
@property (nonatomic, strong, readonly, nullable) OHMySQLStore *store;

/// Nonnull after connection with DB.
@property (nonatomic, strong, readonly, nullable) OHMySQLConfiguration *configuration;

/// Nonnull after connection with DB. You don't need to use this property at all.
@property (readonly, nullable) void *mysql NS_REFINED_FOR_SWIFT;

/// Pings the server and indicates whether the connection to the server is working.
@property (assign, readonly, getter=isConnected) BOOL connected;

/// One of the protocols. Needs to be set before calling -connect.
@property (nonatomic, assign) OHProtocolType protocol;

/// The default character set for the current connection. By default UTF-8.
@property (nonatomic, assign) CharsetEncoding encoding;

- (nonnull instancetype)initWithConfiguration:(nonnull OHMySQLConfiguration *)configuration;

/// Attempts to disconnect and then establish a connection to a MySQL database engine. Also tries establish SSL connection if it is specified.
- (BOOL)reconnect;

/// Attempts to establish a connection to a MySQL database engine. Also tries establish SSL connection if it is specified.
- (BOOL)connect;

/**
 *  @param database Name of the target db.
 *
 *  @return Zero for success. Nonzero if an error occurred (see enum).
 */
- (OHResultErrorType)selectDataBase:(nonnull NSString *)database;

/// Closes a previously opened connection.
- (void)disconnect;

/**
 *  Asks the database server to shut down. The connected user must have the SHUTDOWN privilege.
 *
 *  @return Zero for success. Nonzero if an error occurred.
 */
- (OHResultErrorType)shutdown;

/**
 *  Flushes tables or caches, or resets replication server information. The connected user must have the RELOAD privilege.
 *
 *  @param options A bit mask composed from any combination.
 *
 *  @return Zero for success. Nonzero if an error occurred (see enum).
 */
- (OHResultErrorType)refresh:(OHRefreshOption)options;

/**
 *  Checks whether the connection to the server is working. If the connection has gone down and auto-reconnect is enabled an attempt to reconnect is made.
 *
 *  @return Zero if the connection to the server is active. Nonzero if an error occurred. A nonzero return does not indicate whether the MySQL server itself is down; the connection might be broken for other reasons such as network problems.
 */
- (OHResultErrorType)pingMySQL __attribute__((warn_unused_result));

@end

Swift

class MySQLStoreCoordinator : NSObject

Undocumented

  • Nonnull after connection with DB.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly, nullable) OHMySQLStore *store;

    Swift

    var store: OHMySQLStore? { get }
  • Nonnull after connection with DB.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly, nullable) OHMySQLConfiguration *configuration;

    Swift

    var configuration: OHMySQLConfiguration? { get }
  • Nonnull after connection with DB. You don’t need to use this property at all.

    Declaration

    Objective-C

    @property (readonly, nullable) void *mysql;
  • Pings the server and indicates whether the connection to the server is working.

    Declaration

    Objective-C

    @property (readonly, getter=isConnected) BOOL connected;

    Swift

    var isConnected: Bool { get }
  • One of the protocols. Needs to be set before calling -connect.

    Declaration

    Objective-C

    @property (nonatomic) OHProtocolType protocol;

    Swift

    var `protocol`: ProtocolType { get set }
  • The default character set for the current connection. By default UTF-8.

    Declaration

    Objective-C

    @property (nonatomic) CharsetEncoding encoding;

    Swift

    var encoding: CharsetEncoding { get set }
  • Undocumented

    Declaration

    Objective-C

    - (nonnull instancetype)initWithConfiguration:(nonnull OHMySQLConfiguration *)configuration;

    Swift

    init(configuration: OHMySQLConfiguration)
  • Attempts to disconnect and then establish a connection to a MySQL database engine. Also tries establish SSL connection if it is specified.

    Declaration

    Objective-C

    - (BOOL)reconnect;

    Swift

    func reconnect() -> Bool
  • Attempts to establish a connection to a MySQL database engine. Also tries establish SSL connection if it is specified.

    Declaration

    Objective-C

    - (BOOL)connect;

    Swift

    func connect() -> Bool
  • Declaration

    Objective-C

    - (OHResultErrorType)selectDataBase:(nonnull NSString *)database;

    Swift

    func selectDataBase(_ database: String) -> ResultErrorType

    Parameters

    database

    Name of the target db.

    Return Value

    Zero for success. Nonzero if an error occurred (see enum).

  • Closes a previously opened connection.

    Declaration

    Objective-C

    - (void)disconnect;

    Swift

    func disconnect()
  • Asks the database server to shut down. The connected user must have the SHUTDOWN privilege.

    Declaration

    Objective-C

    - (OHResultErrorType)shutdown;

    Swift

    func shutdown() -> ResultErrorType

    Return Value

    Zero for success. Nonzero if an error occurred.

  • Flushes tables or caches, or resets replication server information. The connected user must have the RELOAD privilege.

    Declaration

    Objective-C

    - (OHResultErrorType)refresh:(OHRefreshOption)options;

    Swift

    func refresh(_ options: RefreshOption) -> ResultErrorType

    Parameters

    options

    A bit mask composed from any combination.

    Return Value

    Zero for success. Nonzero if an error occurred (see enum).

  • Checks whether the connection to the server is working. If the connection has gone down and auto-reconnect is enabled an attempt to reconnect is made.

    Declaration

    Objective-C

    - (OHResultErrorType)pingMySQL;

    Swift

    func pingMySQL() -> ResultErrorType

    Return Value

    Zero if the connection to the server is active. Nonzero if an error occurred. A nonzero return does not indicate whether the MySQL server itself is down; the connection might be broken for other reasons such as network problems.