fmdb

How to use fmdb for a login page?

你离开我真会死。 提交于 2019-12-02 07:02:58
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 succeeded in entering the data into the database,in the registerViewController but I want to enter code

Convert NSArray into array of JSON objects

青春壹個敷衍的年華 提交于 2019-12-02 02:35:01
问题 I'd like to create a JSON array of objects from the resultsArray. NSMutableArray *resultsArray = [NSMutableArray array]; FMResultSet *resultsSet = [database executeQuery:queryString]; while ([resultsSet next]) { [resultsArray addObject:[resultsSet resultDictionary]]; } For clarification, I'm using FMDB to query a database. I'm then storing the resulting objects within the resultsArray. From here I want to convert that results array into a JSON array of objects. 回答1: You can use

Convert NSArray into array of JSON objects

故事扮演 提交于 2019-12-01 23:52:09
I'd like to create a JSON array of objects from the resultsArray. NSMutableArray *resultsArray = [NSMutableArray array]; FMResultSet *resultsSet = [database executeQuery:queryString]; while ([resultsSet next]) { [resultsArray addObject:[resultsSet resultDictionary]]; } For clarification, I'm using FMDB to query a database. I'm then storing the resulting objects within the resultsArray. From here I want to convert that results array into a JSON array of objects. Andrew You can use NSJSONSerialization class to create a JSON file from your dictionary using the class method NSData * JSONData =

FMDB query isn't acting right with LIKE

我是研究僧i 提交于 2019-12-01 15:23:26
I am using FMDB, which is a wrapper for SQLite. http://github.com/ccgus/fmdb Here is my query line: FMResultSet *athlete = [db executeQuery:@"SELECT * FROM athletes WHERE athlete_name LIKE ?", search_text]; Using this I can get a result back if I type in the exact name of the athlete. But, I'm trying to use LIKE so I can search on the name. But, when I add %?% instead of just ? ... nothing returns. And there are no errors. Has anyone ran into this before and know what I'm doing wrong? Thanks everyone! The wildcard characters ( % ) have to be part of the substituted variable, not the query

FMDB query isn't acting right with LIKE

大城市里の小女人 提交于 2019-12-01 14:19:21
问题 I am using FMDB, which is a wrapper for SQLite. http://github.com/ccgus/fmdb Here is my query line: FMResultSet *athlete = [db executeQuery:@"SELECT * FROM athletes WHERE athlete_name LIKE ?", search_text]; Using this I can get a result back if I type in the exact name of the athlete. But, I'm trying to use LIKE so I can search on the name. But, when I add %?% instead of just ? ... nothing returns. And there are no errors. Has anyone ran into this before and know what I'm doing wrong? Thanks

Setting user_version in sqlite

▼魔方 西西 提交于 2019-11-30 15:57:36
I have seen other questions on here about reading the user_version, and that seems to be working fine for me. However I'm trying to use sqlite in FMDB to set my version number and it isn't setting. _db = [self openDatabase]; [_db executeUpdate:[StudentController creationString]]; [_db executeUpdate:[ReadingController creationString]]; [_db executeUpdate:[SessionController creationString]]; NSLog(@"User version is %i", userVersion); NSString *query = [NSString stringWithFormat:@"PRAGMA USER_VERSION = %i", userVersion]; [_db executeQuery:query]; the output I get is: 2014-01-16 22:16:25.438 MyApp

iOS开发之FMDB的是本使用

谁都会走 提交于 2019-11-30 15:10:55
FMDB是将sqlite3的语法封装成OC的语法 基于sqlite3的 使用的步骤: 1.创建打开一个数据库 2.向数据库里添加一个表 3.数据的增删改查 首先这里要使用一个第三方库fmdb,导入这个之后,操作如下添加-fno-objc-arc 然后连接库中连接libsqlite3 代码如下: // // ViewController.m // 01-FMDB 的基本适用 // // Created byon 16/5/4. // Copyright (c) 2016 年 鹿微微鹿 . All rights reserved. // //FMDB 将 sqlite3 的语法封装成了 OC 的语法 // 基于 sqlite3 // 适用步骤 :1. 创建打开一个数据库 //2. 向数据库里添加一个表 //3. 数据的增删改查 #import "ViewController.h" #import "FMDatabase.h" @interface ViewController (){ FMDatabase *_db ; } @end @implementation ViewController - ( void )viewDidLoad { [ super viewDidLoad ]; //1. 创建 / 打开数据库 [ self createDB ]; //2. 添加表 [ self

Passing an array to sqlite WHERE IN clause via FMDB?

落爺英雄遲暮 提交于 2019-11-30 11:34:57
Is it possible to pass an array to a SELECT … WHERE … IN statement via FMDB? I tried to implode the array like this: NSArray *mergeIds; // An array with NSNumber Objects NSString *mergeIdString = [mergeIds componentsJoinedByString:@","]; NSString *query = @"SELECT * FROM items WHERE last_merge_id IN (?)"; FMResultSet *result = [database executeQuery:query, mergeIdString]; This only works if there is exactly 1 object in the array, which leads me to believe that FMDB adds quotes around the whole imploded string. So I tried passing the array as is to FMDB's method: NSArray *mergeIds; // An array

How Can I Save & Retrieve an image (bytes) to SQLite (blob) using FMDB?

烈酒焚心 提交于 2019-11-30 07:42:59
I'm making an iOS App that need to show some images from a remote site (from an URL), and everytime the users enter to the screen that should show the image, the app get freeze until the download is completed. So I want to store the images already downloaded into a SQLite Table named COVERS. Here is the code that how I'm downloading and Showing the image: Suppose that movieCover is an UIImageView and the object movie has a NSURL property named cover that contains the URL of the image to be downloaded. NSData *cover = [[NSData alloc] initWithContentsOfURL:movie.cover]; movieCover.image = [

Setting user_version in sqlite

扶醉桌前 提交于 2019-11-29 22:00:46
问题 I have seen other questions on here about reading the user_version, and that seems to be working fine for me. However I'm trying to use sqlite in FMDB to set my version number and it isn't setting. _db = [self openDatabase]; [_db executeUpdate:[StudentController creationString]]; [_db executeUpdate:[ReadingController creationString]]; [_db executeUpdate:[SessionController creationString]]; NSLog(@"User version is %i", userVersion); NSString *query = [NSString stringWithFormat:@"PRAGMA USER