0

I don't think this is the correct format because the console stops at the nslog retrieving ownership results. Do i need to work around this? create a temp table to store the where for qr and then search for where user? or do can i just update my sql statement?

[database executeQuery:@"select * from ownership where qrcode = ? and user = ?;", ktQRcode, userktid];

NSLog(@"retrieving ownership results through qrcode and userid");

while ([results next]) {

    OWNERSHIP *ktownership = [OWNERSHIP new];

    ktownership.uniqueIDownership = [results intForColumn:@"id"];

    ktownership.user = [results intForColumn:@"user"];

    ktownership.qrcode = [results intForColumn:@"qrcode"];

    ktownership.create_at = [results dateForColumn:@"create_at"];

    [foundOwnership addObject:ktownership];

    ownershipcount = [foundOwnership count];

    NSLog(@"addnewownership count: %lu", foundOwnership.count);

    NSLog(@"addnewownership Array: %@", foundOwnership);
Paulw11
  • 108,386
  • 14
  • 159
  • 186
Jim Chen
  • 157
  • 1
  • 3
  • 11
  • 1
    What do you mean "it stops" - do you get an error message or stack trace? Have you accidentally set a breakpoint (blue flag in the margin) on that line? – Paulw11 Oct 13 '14 at 19:15

1 Answers1

0

You don't show us where you assign results variable. You should also check for failure, e.g.:

FMResultSet *results = [database executeQuery:@"select * from ownership where qrcode = ? and user = ?;", ktQRcode, userktid];

if (!results) {
    NSLog(@"select error: %@", [database lastErrorMessage]);
} else {
    NSLog(@"retrieving ownership results through qrcode and userid");
}

while ([results next]) {

    OWNERSHIP *ktownership = [OWNERSHIP new];

    // the rest of your code here
}
Rob
  • 415,655
  • 72
  • 787
  • 1,044
  • Ok so I did that, but im not getting an error message – Jim Chen Oct 13 '14 at 19:24
  • So what im doing now is selecting only where qrcode = ? – Jim Chen Oct 13 '14 at 19:25
  • and then im only adding the results to my array if ktownership.user == userid – Jim Chen Oct 13 '14 at 19:25
  • I don't understand the question: Are you saying that when you add the `user` condition to your `where` clause that you're not getting any records, but that if you omit it from the SQL, you're getting a lot of records, including the one you originally were looking for? You definitely should not have to retrieve everything and then manually filter it. It sounds like there's some simple data issue, but it's not at all clear what the issue is on the basis of the limited information provided. – Rob Oct 13 '14 at 19:35