bonjour tous le monde.
on essaie de se connecter a une base de données mysql pour cela on utilise le script suivant pas d'erreur mais il ne donne pas de résultat il donne des nulls
ce script est en objective C mais je l'apelle depuis Aple script studio
merci
on essaie de se connecter a une base de données mysql pour cela on utilise le script suivant pas d'erreur mais il ne donne pas de résultat il donne des nulls
ce script est en objective C mais je l'apelle depuis Aple script studio
Bloc de 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)];
}