fmdb

FMDB resultset into dictionary

淺唱寂寞╮ 提交于 2019-12-03 12:25:56
问题 Is there an easy way to get the FMDB results of an executeQuery:SELECT * ... easily into a dictionary? FMResultSet *appointmentResults = [[DataClass getDB] executeQuery:@"SELECT * FROM Appointments WHERE date = ?",currDateString]; while ([appointmentResults next]) { //Create dictionary //Add dictionary to array for later use } I was wondering if there was a way I could make the dictionary keys the column names and the values the column values. Preferably without having to do a loop through

FMDB and encryption

匿名 (未验证) 提交于 2019-12-03 08:50:26
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using FMDB to work with sqlite and I'd prefer to avoid a dependency on SQLCipher. How can I simply leverage the DataProtection capability built into iOS? Is this possible - the only requirement is to protect the data in the event of the phone being stolen. If the phone is unlocked with a PIN, it's fine that the user could access the DB - it's their data. 回答1: Look for the line where you do databaseWithPath: (or initWithPath: ), then add: FMDatabase *db = [FMDatabase databaseWithPath:path]; NSDictionary *attributes = @{NSFileProtectionKey

FMDB SQLite question: row count of a query?

帅比萌擦擦* 提交于 2019-12-03 05:43:56
问题 does anyone know how to return the count of a query when using FMDB? If I executeQuery @"select count(*) from sometable were..." I get an empty FMResultSet back. How can I get the row count of the query? Do I need to do a query like "select * from sometable where.." and iterate through the result set? Or can I use useCount or whats the best way (in terms of performance) to do this? Thanks! 回答1: Shorter code to accomplish the same thing: NSUInteger count = [db intForQuery:@"SELECT COUNT(field)

How to save & retrieve NSdata into sqlite through FMDB

对着背影说爱祢 提交于 2019-12-03 05:19:57
问题 How can I save NSData into sqlite, I am using FMDB wrapper for saving data. Below is the code which I have tried so far For saving NSData *data = [NSKeyedArchiver archivedDataWithRootObject:model.expertArray];; NSString *query = [NSString stringWithFormat:@"insert into save_article values ('%@','%@','%@','%@','%@','%@')", model.Id, model.title, model.earliestKnownDate, data, model.excerpt,model.image_url]; For Retriving while([results next]) { NSData *data = [results dataForColumn:@"experts"]

How to save & retrieve NSdata into sqlite through FMDB

﹥>﹥吖頭↗ 提交于 2019-12-02 18:36:50
How can I save NSData into sqlite, I am using FMDB wrapper for saving data. Below is the code which I have tried so far For saving NSData *data = [NSKeyedArchiver archivedDataWithRootObject:model.expertArray];; NSString *query = [NSString stringWithFormat:@"insert into save_article values ('%@','%@','%@','%@','%@','%@')", model.Id, model.title, model.earliestKnownDate, data, model.excerpt,model.image_url]; For Retriving while([results next]) { NSData *data = [results dataForColumn:@"experts"]; NSMutableArray *photoArray = [NSKeyedUnarchiver unarchiveObjectWithData:data]; } I have tried both

FMDB usage with swift - returning a boolean

℡╲_俬逩灬. 提交于 2019-12-02 17:40:29
问题 I am currently building an app in swift that uses FMDB to interact with a database that is stored on the device. I chose to use FMDB since I have experience using it with Objective C, and it says it supports swift. I am having problems with returning booleans in swift when executing a statement. Here is an image of the update functions available to me when using FMDB in an Objective C class, notice how the overwhelming majority return bools And here are the funcs available in swift: Doesn't

Date entry into database through GUI for Date which is readable by FMDatabase

懵懂的女人 提交于 2019-12-02 17:28:45
问题 I have a set of events which I will have to feed into the database before I ship the app so that the application is ready to read from this database. I have seen some posts like these which explain how to enter NSDate into database so that it can be read back: iPhone SQLite date problem Persisting Dates to SQLite3 in an iPhone Application Now, I want to entry dates into the database by running queries like: insert into VendorEvents (event_start, event_end, notes, event_name) values (date(

第三方库 FMDB的使用

岁酱吖の 提交于 2019-12-02 15:30:58
数据库的使用 总结自: http://www.cnblogs.com/wuhenke/archive/2012/02/07/2341656.html // SQLite的大小写敏感性,不区分带小写。下面的UPDATE 可以写成小写的不过要用双引号引起来。工程里的对比着。 // 直到有一次在網路上發現了FMDB這個東西,才發現不是SQLite很難學,而是SQLite的C API對初學者來說實在太麻煩太瑣碎,難度太高,難怪我怎麼學都學不會。 FMDB說穿了其實只是把C API包裝成簡單易用的Objective-C物件。不過這對我這個SQLite初學者來說,可是大大減低了上手的難度。有了FMDB,寫程式時只要專心在SQLite的語法上,而不用去理那堆有看沒有懂的C API,實在是件快樂的事情。 // 1 打开,关闭资料库 // 使用资料库的第一件事,就是建立一个资料库。要注意的是,在ios环境下,只有document directory是可以进行读写的。在写程序时用的那个Resource资料夹下的东西都是read-only,因此,建立的资料库要放在document资料夹下。 + (void)fun1 { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,

Date entry into database through GUI for Date which is readable by FMDatabase

无人久伴 提交于 2019-12-02 12:22:46
I have a set of events which I will have to feed into the database before I ship the app so that the application is ready to read from this database. I have seen some posts like these which explain how to enter NSDate into database so that it can be read back: iPhone SQLite date problem Persisting Dates to SQLite3 in an iPhone Application Now, I want to entry dates into the database by running queries like: insert into VendorEvents (event_start, event_end, notes, event_name) values (date('2012-01-26'), date('2012-01-26'), 'Republic day of India is the day when our constitution was framed and

FMDB usage with swift - returning a boolean

别等时光非礼了梦想. 提交于 2019-12-02 09:03:07
I am currently building an app in swift that uses FMDB to interact with a database that is stored on the device. I chose to use FMDB since I have experience using it with Objective C, and it says it supports swift. I am having problems with returning booleans in swift when executing a statement. Here is an image of the update functions available to me when using FMDB in an Objective C class, notice how the overwhelming majority return bools And here are the funcs available in swift: Doesn't give me much to work with! Here is an existing query I am currently using in an app (with names changed)