PerfectlySoft / Perfect-MySQL

A stand-alone Swift wrapper around the MySQL client library, enabling access to MySQL servers.
https://www.perfect.org
Apache License 2.0
128 stars 61 forks source link

Add support for mysql_set_server_option #38

Closed 123FLO321 closed 5 years ago

123FLO321 commented 6 years ago

Added support for mysql_set_server_option

Example:

let mysql = MySQL()
mysql.connect(host: host, user: username, password: password, db: database)
mysql.setServerOption(.MYSQL_OPTION_MULTI_STATEMENTS_ON)
let sql = """
  INSERT INTO test (field1, field2)
  VALUES ("Hello", "World");
  INSERT INTO test (field1, field2)
  VALUES ("World", "Hello");
"""
mysql.query(statement: sql) 

If MYSQL_OPTION_MULTI_STATEMENTS_ON is not set (or MYSQL_OPTION_MULTI_STATEMENTS_OFF is set again) this sql will throw an error as usual.

This feature allows for example the creation of TRIGGERs in Perfect-MySQL