-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathSQL.swift
More file actions
44 lines (39 loc) · 1015 Bytes
/
SQL.swift
File metadata and controls
44 lines (39 loc) · 1015 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// SQL.swift
// PostgresStORM
//
// Created by Jonathan Guthrie on 2016-09-24.
//
//
import StORM
import PerfectMySQL
import PerfectLogger
/// An extension to the main class providing SQL statement functions
extension MySQLStORM {
/// Execute Raw SQL (with parameter binding)
public func sql(_ statement: String, params: [String]) throws {
do {
try exec(statement, params: params)
} catch {
if !MySQLConnector.quiet {
LogFile.error("Error msg: \(error)", logFile: StORMDebug.location)
}
self.error = StORMError.error("\(error)")
throw error
}
}
/// Execute Raw SQL (with parameter binding)
/// Returns [StORMRow] (discardable)
@discardableResult
public func sqlRows(_ statement: String, params: [String]) throws -> [StORMRow] {
do {
return try execRows(statement, params: params)
} catch {
if !MySQLConnector.quiet {
LogFile.error("Error msg: \(error)", logFile: StORMDebug.location)
}
self.error = StORMError.error("\(error)")
throw error
}
}
}