connection a une base de donées mysql depuis cocoa

issamneo

Membre confirmé
6 Décembre 2006
13
0
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
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)];
}
merci
 
voici le code erreur que je reçoit:

Bloc de 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)
 
voici le code erreur que je reçoit:

Bloc de 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)

oui c'est mach-o ppc que tu essayes de loader sur une arch x86 :D:rateau::p