fmdb

How to delete a row in a sqlite database table?

不想你离开。 提交于 2019-12-22 05:13:29
问题 I am using fmdb for managing my database. I could not find any example for deleting a row from a table in fmdb. I tried NSString *sqlStat=@"DELETE from tableName WHERE id=3"; FMResultSet *rs = [database executeQuery:sqlStat]; but its not working because when I checked the total number of entries in table, I am getting the same number as before executing the above statement. So, what is a proper way to delete a row from a table using fmdb? 回答1: FMDB can be a little finicky if you dont pass in

How to use fmdb for a login page?

主宰稳场 提交于 2019-12-20 04:58:11
问题 I have a login page that has 2 textfields for username & password and a few buttons. I want to know that how I can use fmdb for checking if the username/password combination exists in my database? I also have another viewcontroller used for the user registeration page, having 4 textfields for username, password, email, contact number and a button to input the entered text into the database. How can I save the entered text in 4 fields to the database? Thanks in advance. Here is my code: I

When to close SQLite database (using FMDB)

徘徊边缘 提交于 2019-12-18 16:51:09
问题 When should you close the connection to an SQLite database (using [db close] in FMDB)? Right now I am closing it after running every batch of related queries, but should I rather close when my app closes? What are the pros/cons of doing either way? Thanks 回答1: I'm the guy who wrote FMDB. Keep it open unless you change your schema. That's the only reason to close it, and constantly re-opening it is a little hit on performance / battery life. 来源: https://stackoverflow.com/questions/15720272

Core Data VS Sqlite or FMDB…?

孤人 提交于 2019-12-17 17:24:43
问题 Now this might look like a duplicate thread, but my question is that I have read a lot of questions like.. Core Data vs SQLite 3 and others but these are 2-3 years old. I have also read that FMDB was developed as core data was not supported on iOS, So it should not be used any more. And on the other hand I have read that one should not use core data as a database. So I am seriously confused,whether I should use core data for object storage or not . I mean on what basis I should decide which

Updating SQLITE query FMDB - Beginner

允我心安 提交于 2019-12-13 19:14:49
问题 I could read from my SQLITE DB, but unable to update it. I wonder if the database is writable. When i copy the SQL to the SQL console the code gets executed successfully. So there's no problem with the SQL. -(BOOL) updateScores{ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"uniques.sqlite"]; FMDatabase* db =

Efficiently create placeholder template NSString with NSArray of values

喜欢而已 提交于 2019-12-13 16:12:14
问题 I am trying to make a utility method for FMDB which will take an NSArray of values and return a string of placeholders for use in an IN statement based on the number of values in the array. I can't think of an elegant way of creating this string, am I missing some NSString utility method: // The contents of the input aren't important. NSArray *input = @[@(55), @(33), @(12)]; // Seems clumsy way to do things: NSInteger size = [input count]; NSMutableArray *placeholderArray = [[NSMutableArray

Fmdb Select query with variable table name

陌路散爱 提交于 2019-12-13 06:19:30
问题 I want to get results from different tables, tables are selected by the user. So, I am using table name as variable but it returns nil query. FMResultSet *query = [db1 executeQuery:@"SELECT Image, Explanation FROM %@ WHERE Image !='empty'" "UNION SELECT Image, Explanation FROM %@ WHERE Image !='empty'" "UNION SELECT Image, Explanation FROM %@ WHERE Image !='empty'" "UNION SELECT Image, Explanation FROM %@ WHERE Image !='empty'" "UNION SELECT Image, Explanation FROM %@ WHERE Image !='empty'"

FMDB executeUpdate DROP command does halt the app

非 Y 不嫁゛ 提交于 2019-12-12 11:18:29
问题 I want to drop a table in my SQLite Database file named database.db. After using NSLog(@"i show up in the console"); [db executeUpdate:@"DROP TABLE IF EXISTS `article`;"]; NSLog(@"i will not show up in the console"); the app stops at the position of the query. NSLog before the query is shown in console. NSlog directly after the query does not show up in the console window. Additionally a temporary file called database.db-journal is created and deleted continuously in the simulator app folder

ios fmdb memory leaks

眉间皱痕 提交于 2019-12-12 02:48:49
问题 hi Im asking this question for my friend, who is struggling with this fmdb memory issue. his project read a list from a db, and he opens the db and read the data for each cell, (which is not a good idea but he did), in init, init the database queue, databaseQueue = [[FMDatabaseQueue alloc] initWithPath:_dbPath]; in cellForRowAtIndexPath, use configCell to do things - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *

Is there any way to be notified when sqlite tables update?

不羁的心 提交于 2019-12-12 01:38:41
问题 I am developing an iOS app that uses sqlite database with the help of FMDB . I used to work with Core Data , but it was very slow with 5000 items insert at a time. FMDB with transactions make such inserts much more faster! Also I need some mechanism that can notify my view controllers when some items from sqlite table are updated. NSFetchedResultsController was my solution, but since I use FMDB I can no longer use NSFetchedResultsController . Is there any way to be notified when sqlite tables