Search code examples
iphoneobjective-csqlitewrapperfmdb

FMDB SQLite wrapper and user defined/custom functions


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.


Solution

  • 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