From 12fff65625d15ff8d9c04cdfe4db8b04a6361390 Mon Sep 17 00:00:00 2001 From: dannylewis-sheffield Date: Tue, 25 Oct 2016 13:43:52 +0100 Subject: [PATCH] Added bind param for Any Allows for something like: params.flatMap{$0}.map { mysqlStatement.bindParam($0) } --- Sources/MySQL/MySQL.swift | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Sources/MySQL/MySQL.swift b/Sources/MySQL/MySQL.swift index 1c27b4c..563ab00 100644 --- a/Sources/MySQL/MySQL.swift +++ b/Sources/MySQL/MySQL.swift @@ -766,7 +766,22 @@ public final class MySQLStmt { let r = mysql_stmt_param_count(self.ptr!) return Int(r) } - + + public func bindParam(_ v: Any) { + switch v { + case is Double: + self.bindParam(v as! Double) + case is Int: + self.bindParam(v as! Int) + case is UInt64: + self.bindParam(v as! UInt64) + case is String: + self.bindParam(v as! String) + default: + self.bindParam() + } + } + func bindParam(_ s: String, type: enum_field_types) { let convertedTup = MySQL.convertString(s) self.paramBinds?[self.paramBindsOffset].buffer_type = type