ParameterBindable
public protocol ParameterBindable
A type that can bind its value directly to a parameter in an SQLite statement.
The implementation should use one of the sqlite_bind_X() functions documented at Binding Values To Prepared Statements.
For example, the implementation for Int64 is:
extension Int64: ParameterBindable {
public func bind(to stmt: SQLitePreparedStatement, parameter idx: Int32) throws {
guard sqlite3_bind_int64(stmt, idx, self) == SQLITE_OK else {
throw SQLiteError("Error binding Int64 \(self) to parameter \(idx)", takingDescriptionFromStatement: stmt)
}
}
}
-
Binds the value of
selfto the SQL parameter atidxinstmt.Note
Parameter indexes are 1-based. The leftmost parameter in a statement has index 1.
Requires
index > 0Requires
index < parameterCountThrows
An error if
idxis out of bounds orselfcouldn’t be boundDeclaration
Swift
func bind(to stmt: SQLitePreparedStatement, parameter idx: Int32) throwsParameters
stmtAn
sqlite3_stmt *objectidxThe index of the SQL parameter to bind
View on GitHub
ParameterBindable Protocol Reference