
January 9th, 2007, 03:24 AM
|
 |
a matrix member
|
|
Join Date: Apr 2004
Location: Tunisia
Posts: 170
 
Time spent in forums: 1 Day 12 h 26 m 11 sec
Reputation Power: 5
|
|
|
Problem = cocoa + framework smysql
hi all,
i'm trying to connect on a distant mysql DB using cocoa and the frameworks smysql. the code we copy/paste (with some modification) it from the sourceforge project cocoamysql, when we test the project everything is ok, when we try our code that we get from the project it shows error.
this is the code:
Code:
+ (NSDictionary *)setConnection {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
//MCPConnection *connection, *connect2, *mySQLConnection;
//MCPResult *result;
NSArray *names, *types;
NSDictionary *row;
unsigned int count, i, code;
char *aBigIntegerAsString = "18446744073709551612";
NSLog(@"A big integer (64b required) : string : %s, as integer (using strtoull) : %llu, NSNumber :%@", aBigIntegerAsString, strtoull(aBigIntegerAsString, NULL, 0), [MCPNumber numberWithUnsignedLongLong:strtoull(aBigIntegerAsString, NULL, 0)]);
printf("The value of the strtoull functions is : %llu\n\n", strtoull(aBigIntegerAsString, NULL, 0));
printf("The value of the strtoll functions is : %lli\n\n", strtoll(aBigIntegerAsString, NULL, 0));
NSLog(@"And now, the NSNumber again, but this time asking for the unsigned value : %llu", [[MCPNumber numberWithUnsignedLongLong:strtoull(aBigIntegerAsString, NULL, 0)] unsignedLongLongValue]);
connection = [[MCPConnection alloc] initToHost:@"localhost" withLogin:@"root" password:@"root" usingPort:8889];
[connection selectDB:@"coiffure_tv"];
mySQLConnection = [[MCPConnection alloc] initToHost:"localhost"
withLogin:"root"
password:"root"
usingPort:8889];
if ( ![mySQLConnection isConnected] )
code = 2;
else code = 1;
NSLog (@"Resultat Connection : \n%s", connection);
result = [connection queryString:@"SELECT * FROM Videos"];
count = [result numOfFields];
NSLog (@"Resultat requette : \n%d", count);
names = [result fetchFieldsName];
types = [result fetchTypesAsArray];
[connection release];
connect2 = [[MCPConnection alloc] init];
//[connect2 setConnectionOption:CLIENT_SSL toValue:NO];
[connect2 connectWithLogin:@"root" password:@"root" host:@"localhost" port:8889 socket:nil];
[connect2 selectDB:@"coiffure_tv"];
result = [connect2 listTables];
NSLog (@"Using connect2 : Here is the NSLog of a MCPResult (listTables) : \n%@", result);
result = [connect2 queryString:@"select * from Videos"];
NSLog (@"Using connect2 : content of table Videos : \n%@", result);
NSLog (@"Here comes the last error information : %@\n", [connect2 getLastErrorMessage]);
[connect2 release];
[pool release];
//return [NSNumber numberWithInt:(count)];
return [NSNumber numberWithInt:(code)];
}
and this is the error:
Code:
Building ZeroLink launcher /Users/imac/connect_mysql/build Debug/connect_mysql.app/Contents/MacOS/connect_mysql (1 warning)
warning /Users/imac/connect_mysql/SMySQL_static.framework SMySQL_static cputype (18, architecture ppc) does not match cputype (7) for specified -arch flag: i386 (file not loaded)
__________________
THE MATRIX HAS YOU
-------------------------------
end transmission
-------------------------------
|