FMDB SQLite 包装器和用户定义/自定义函数
我目前正在将 FMDB 用于 iPhone 应用程序,我发现它......好吧。它确实是一个很棒的小型 SQLite 包装器。
FMDB GitHub: https://github.com/ccgus/fmdb
唯一的问题是我需要使用自定义功能。在 SQLite 中,我可以通过使用以下语法轻松地做到这一点:
sqlite3_create_function(database, "custom", 4, SQLITE_UTF8, NULL, &customFunc, NULL, NULL);
除了 FMDB,我认为没有办法使用自定义函数?
如果我错了请纠正我。任何帮助将不胜感激。
I'm using FMDB for an iPhone app at the moment and I'm finding it... okay. It's a great little SQLite wrapper indeed.
FMDB GitHub:
https://github.com/ccgus/fmdb
The only problem is I'm needing to use a custom function. In SQLite I can easily do this by using the following syntax:
sqlite3_create_function(database, "custom", 4, SQLITE_UTF8, NULL, &customFunc, NULL, NULL);
Except with FMDB I don't think there's a way to use a custom function?
Correct me if I'm wrong. Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要 FMDatabase 的 makeFunctionNamed:maximumArguments:withBlock: 方法:
https://github.com /ccgus/fmdb#making-custom-sqlite-functions-based-on-blocks
https://github.com/ccgus/fmdb/blob/master/src/fmdb。 m#L1033
You want FMDatabase's makeFunctionNamed:maximumArguments:withBlock: method:
https://github.com/ccgus/fmdb#making-custom-sqlite-functions-based-on-blocks
https://github.com/ccgus/fmdb/blob/master/src/fmdb.m#L1033
FMDB 是开源的,您可以添加一个包装方法来包装创建新的 SQLite 函数。应该不难。您可以使用其他包装器方法作为模板来完成此任务。
也许您可以将您的补充贡献回社区?
FMDB is open source, you could add a wrapper method to wrap up creating a new SQLite function. Shouldn't be difficult. You can use the other wrapper methods as templates for how you should accomplish this.
Maybe you could contribute your additions back to the community?
我知道这是一个老问题,但以下应该可行:
显然,您可以使用
custom
和customFunc
(或其他)代替distance 和
distanceFunc
但你明白了。I know this is an old question, but the following should work:
Obviously, you'd use
custom
andcustomFunc
(or whatever) in place ofdistance
anddistanceFunc
but you get the idea.