- 使用Swift语言
- 方便使用,链式语法。
需继承DBTableType协议
enum UserInfo: String, DBTableType {
static let table_name = "UserInfo"
case userid
case username
case password
case phonenum
var type: DataBaseColumnType {
switch self {
case .userid: return .Integer
case .username: return .Text
case .password: return .Text
case .phonenum: return .Text
}
}
var option: DataBaseColumnOptions {
switch self {
case .userid: return .PrimaryKeyAutoincrement
case .username: return .NotNull
case .password: return .NotNull
case .phonenum: return .None
}
}
}
let sql = SQL<UserInfo>().SELECT.COUNT(.username, .phonenum, .username).FROM(UserInfo).WHERE(.username == 2)
let sql = SQL2<UserInfo, PayInfo>()
sql.SELECT([.password, .phonenum], [.money, .product]).FROM(UserInfo.self, PayInfo.self).WHERE(.userid == .userid).AND(.money == .null)
let sql = SELECT * FROM(UserInfo).LEFT.JOIN(PayInfo).ON(.userid == .userid).WHERE(.password != password)
let sql = DELETE.FROM(PayInfo).WHERE(.userid == 5)
let sql = INSERT.OR.REPLACE.INTO(UserInfo)[.userid, .password, .username].VALUES(1,”12345”,”fenfen”)
let sql = UPDATE(PayInfo).SET(.money == 9, .product == "3322").WHERE(.money + 8 - 9 != 9)
FFSQLite is available under the MIT license. See [the LICENSE file](./LICENSE.txt) for more information.