From c506398bb7f92644c04f542c067a761e8eee77ee Mon Sep 17 00:00:00 2001 From: Bibiko Date: Mon, 20 Jul 2009 20:27:59 +0000 Subject: =?UTF-8?q?=E2=80=A2=20fixed:=20if=20SPTableData=20returns=20for?= =?UTF-8?q?=20dict:=20tableStatus=20key:Rows=20=3D=20NULL=20(as=20for=20in?= =?UTF-8?q?formation=5Fschema=20for=20instance)=20then=20try=20to=20get=20?= =?UTF-8?q?the=20number=20of=20rows=20via=20"SELECT=20COUNT(*)=20FROM=20ta?= =?UTF-8?q?ble"=20in=20order=20to=20be=20able=20to=20load=20the=20Content?= =?UTF-8?q?=20Tab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPTableData.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Source/SPTableData.m b/Source/SPTableData.m index 81fe5479..69db2b93 100644 --- a/Source/SPTableData.m +++ b/Source/SPTableData.m @@ -739,6 +739,15 @@ if ([status objectForKey:@"Type"]) { [status setObject:[status objectForKey:@"Type"] forKey:@"Engine"]; } + + // [status objectForKey:@"Rows"] is NULL then try to get the number of rows via SELECT COUNT(*) FROM `foo` + // this happens e.g. for db "information_schema" + if([[status objectForKey:@"Rows"] isKindOfClass:[NSNull class]]) { + tableStatusResult = [mySQLConnection queryString:[NSString stringWithFormat:@"SELECT COUNT(*) FROM %@", [escapedTableName backtickQuotedString] ]]; + if ([[mySQLConnection getLastErrorMessage] isEqualToString:@""]) + [status setObject:[NSNumber numberWithLongLong:[[[tableStatusResult fetchRowAsArray] objectAtIndex:0] longLongValue]] forKey:@"Rows"]; + + } return TRUE; } -- cgit v1.2.3