mysql-cocoa-commits Mailing List for MySQL Objective C API for Cocoa (Page 5)
Brought to you by:
sergecohen
You can subscribe to this list here.
2002 |
Jan
(2) |
Feb
(6) |
Mar
(11) |
Apr
(2) |
May
(40) |
Jun
(17) |
Jul
(2) |
Aug
(2) |
Sep
|
Oct
|
Nov
(4) |
Dec
(11) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(4) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(44) |
Sep
|
Oct
(14) |
Nov
|
Dec
|
2004 |
Jan
|
Feb
|
Mar
(7) |
Apr
|
May
(4) |
Jun
|
Jul
|
Aug
(12) |
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Serge C. <ser...@us...> - 2002-11-29 11:05:33
|
Update of /cvsroot/mysql-cocoa/SMySQL In directory sc8-pr-cvs1:/tmp/cvs-serv17781 Modified Files: SMySQLResult.m Log Message: Corrected error for FIELD_TYPE_DATE, pointed out by moxou <mo...@ma...>. Serge Cohen; MySQL-Cocoa project 2002-11-29. Index: SMySQLResult.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQLResult.m,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SMySQLResult.m 3 Jun 2002 15:05:58 -0000 1.7 --- SMySQLResult.m 29 Nov 2002 11:05:24 -0000 1.8 *************** *** 233,238 **** case FIELD_TYPE_FLOAT: case FIELD_TYPE_DOUBLE: ! theCurrentObj = [NSNumber numberWithDouble:atof(theData)]; ! break; case FIELD_TYPE_TIMESTAMP: // Indeed one should check which format it is (14,12...2) and get the corresponding format string --- 233,238 ---- case FIELD_TYPE_FLOAT: case FIELD_TYPE_DOUBLE: ! theCurrentObj = [NSNumber numberWithDouble:atof(theData)]; ! break; case FIELD_TYPE_TIMESTAMP: // Indeed one should check which format it is (14,12...2) and get the corresponding format string *************** *** 240,256 **** // Here it will crash if it's not default presentation : TIMESTAMP(14) theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y%m%d%H%M%S"]; ! break; case FIELD_TYPE_DATE: theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d"]; ! break; case FIELD_TYPE_TIME: // Pass them back as string for the moment... not TIME object in Cocoa (so far) theCurrentObj = [NSString stringWithUTF8String:theData]; case FIELD_TYPE_DATETIME: theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d %H:%M:%S"]; ! break; case FIELD_TYPE_YEAR: theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y"]; ! break; case FIELD_TYPE_VAR_STRING: case FIELD_TYPE_STRING: --- 240,257 ---- // Here it will crash if it's not default presentation : TIMESTAMP(14) theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y%m%d%H%M%S"]; ! break; case FIELD_TYPE_DATE: theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d"]; ! break; case FIELD_TYPE_TIME: // Pass them back as string for the moment... not TIME object in Cocoa (so far) theCurrentObj = [NSString stringWithUTF8String:theData]; + break; case FIELD_TYPE_DATETIME: theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d %H:%M:%S"]; ! break; case FIELD_TYPE_YEAR: theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y"]; ! break; case FIELD_TYPE_VAR_STRING: case FIELD_TYPE_STRING: *************** *** 364,368 **** // Pass them back as string for the moment... not TIME object in Cocoa (so far) theCurrentObj = [NSString stringWithUTF8String:theData]; ! case FIELD_TYPE_DATETIME: theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d %H:%M:%S"]; break; --- 365,370 ---- // Pass them back as string for the moment... not TIME object in Cocoa (so far) theCurrentObj = [NSString stringWithUTF8String:theData]; ! break; ! case FIELD_TYPE_DATETIME: theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d %H:%M:%S"]; break; |
From: Serge C. <ser...@us...> - 2002-08-22 21:02:48
|
Update of /cvsroot/mysql-cocoa/SMySQL In directory usw-pr-cvs1:/tmp/cvs-serv3329 Modified Files: Tag: version-2 MCPConnection.m MCPResult.m MCPResultPlus.m MCPFastQueries.m Log Message: Modifications of the comment for proper disply in the documentation. Serge Cohen; MySQL Cocoa Porject, 2002-08-22 Index: MCPConnection.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPConnection.m,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -C2 -d -r1.1.2.7 -r1.1.2.8 *** MCPConnection.m 23 Jul 2002 14:56:43 -0000 1.1.2.7 --- MCPConnection.m 22 Aug 2002 21:02:45 -0000 1.1.2.8 *************** *** 132,136 **** - (id) init /*" ! Initialise a MySQLConnection without making a connection, most likely useless, except with #{setConnectionOption:withArgument:}. "*/ { --- 132,136 ---- - (id) init /*" ! Initialise a MySQLConnection without making a connection, most likely useless, except with !{setConnectionOption:withArgument:}. "*/ { *************** *** 241,245 **** - (BOOL) connectWithLogin:(NSString *) login password:(NSString *) pass host:(NSString *) host port:(int) port socket:(NSString *) socket /*" ! The method used by #{initToHost:withLogin:password:usingPort:} and #{initToSocket:withLogin:password:}. Same information and use of the parameters: - login is the user name --- 241,245 ---- - (BOOL) connectWithLogin:(NSString *) login password:(NSString *) pass host:(NSString *) host port:(int) port socket:(NSString *) socket /*" ! The method used by !{initToHost:withLogin:password:usingPort:} and !{initToSocket:withLogin:password:}. Same information and use of the parameters: - login is the user name *************** *** 400,406 **** /*" Takes a query string and return an MCPResult object holding the result of the query. ! The returned MCPResult is not retained, the client is responsible for that (it's autoreleased before being returned). If no field are present in the result (like in an insert query), will return nil (!{difference from previous version implementation}). Though, if their is at least one field the result will be non nil (even if no row are selected). ! Note that if you want to use this method with binary data (in the query), you should use #{prepareBinaryData:} to include the binary data in the query string. Also if you want to include in your query a string containing any special character (\, ', " ...) then you should use #{prepareString}. "*/ { --- 400,406 ---- /*" Takes a query string and return an MCPResult object holding the result of the query. ! The returned MCPResult is not retained, the client is responsible for that (it's autoreleased before being returned). If no field are present in the result (like in an insert query), will return nil (#{difference from previous version implementation}). Though, if their is at least one field the result will be non nil (even if no row are selected). ! Note that if you want to use this method with binary data (in the query), you should use !{prepareBinaryData:} to include the binary data in the query string. Also if you want to include in your query a string containing any special character (\, ', " ...) then you should use !{prepareString}. "*/ { *************** *** 519,523 **** - (MCPResult *) listTables /*" ! Make sure a DB is selected (with !{selectDB} method) first. "*/ { --- 519,523 ---- - (MCPResult *) listTables /*" ! Make sure a DB is selected (with !{selectDB:} method) first. "*/ { *************** *** 695,699 **** /*" Kills the process with the given pid. ! The users needs the #{Process_priv} privilege. "*/ { --- 695,699 ---- /*" Kills the process with the given pid. ! The users needs the !{Process_priv} privilege. "*/ { *************** *** 707,711 **** - (void) disconnect /*" ! Disconnects a connected MCPConnection object; used by #{-dealloc} method. "*/ { --- 707,711 ---- - (void) disconnect /*" ! Disconnects a connected MCPConnection object; used by !{dealloc:} method. "*/ { Index: MCPResult.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPResult.m,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -C2 -d -r1.1.2.6 -r1.1.2.7 *** MCPResult.m 23 Jul 2002 14:56:43 -0000 1.1.2.6 --- MCPResult.m 22 Aug 2002 21:02:45 -0000 1.1.2.7 *************** *** 36,40 **** Hold the results of a query to a MySQL database server. It correspond to the MYSQL_RES structure of the C API, and to the statement handle of the PERL DBI/DBD. ! Uses the #{mysql_store_result()} function from the C API. This object is generated only by a MCPConnection object, in this way (see #{MCPConnection} documentation): --- 36,40 ---- Hold the results of a query to a MySQL database server. It correspond to the MYSQL_RES structure of the C API, and to the statement handle of the PERL DBI/DBD. ! Uses the !{mysql_store_result()} function from the C API. This object is generated only by a MCPConnection object, in this way (see #{MCPConnection} documentation): *************** *** 79,83 **** - (id) initWithMySQLPtr:(MYSQL *) mySQLPtr encoding:(NSStringEncoding) theEncoding /*" ! initialise a MCPResult, it is used internally by MCPConnection #{queryString:} method: the only proper way to get a running MCPResult object. "*/ { --- 79,83 ---- - (id) initWithMySQLPtr:(MYSQL *) mySQLPtr encoding:(NSStringEncoding) theEncoding /*" ! initialise a MCPResult, it is used internally by MCPConnection !{queryString:} method: the only proper way to get a running MCPResult object. "*/ { *************** *** 211,215 **** Return the next row of the result as a collection of type defined by aType (namely MCPTypeArray or MCPTypeDictionary). Each field of the row is made into a proper object to hold the info (NSNumber, NSString...). ! This method returned directly the !{mutable} object generated while going through all the columns "*/ { --- 211,215 ---- Return the next row of the result as a collection of type defined by aType (namely MCPTypeArray or MCPTypeDictionary). Each field of the row is made into a proper object to hold the info (NSNumber, NSString...). ! This method returned directly the #{mutable} object generated while going through all the columns "*/ { *************** *** 357,361 **** Return the next row of the result as an array, the index in select field order, the object a proper object for handling the information in the field (NSString, NSNumber ...). ! Just a !{typed} wrapper for method #{fetchRosAsType:} (with arg MCPTypeArray). --- 357,361 ---- Return the next row of the result as an array, the index in select field order, the object a proper object for handling the information in the field (NSString, NSNumber ...). ! Just a #{typed} wrapper for method !{fetchRosAsType:} (with arg MCPTypeArray). *************** *** 377,381 **** Return the next row of the result as a dictionary, the key being the field name, the object a proper object for handling the information in the field (NSString, NSNumber ...). ! Just a !{typed} wrapper for method #{fetchRosAsType:} (with arg MCPTypeDictionary). --- 377,381 ---- Return the next row of the result as a dictionary, the key being the field name, the object a proper object for handling the information in the field (NSString, NSNumber ...). ! Just a #{typed} wrapper for method !{fetchRosAsType:} (with arg MCPTypeDictionary). *************** *** 434,438 **** Return a collection of the fields's type. The type of collection is choosen by the aType variable (MCPTypeArray or MCPTypeDictionary). ! This method returned directly the !{mutable} object generated while going through all the columns "*/ { --- 434,438 ---- Return a collection of the fields's type. The type of collection is choosen by the aType variable (MCPTypeArray or MCPTypeDictionary). ! This method returned directly the #{mutable} object generated while going through all the columns "*/ { *************** *** 632,636 **** Return YES if the field (by name) with the given index is a BLOB. It should be used to discriminates between BLOBs and TEXTs. ! !{NOT YET IMPLEMENTED}, return YES for both BLOBs and TEXTs... "*/ { --- 632,636 ---- Return YES if the field (by name) with the given index is a BLOB. It should be used to discriminates between BLOBs and TEXTs. ! #{NOT YET IMPLEMENTED}, return YES for both BLOBs and TEXTs... "*/ { Index: MCPResultPlus.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPResultPlus.m,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** MCPResultPlus.m 3 Jun 2002 13:39:24 -0000 1.1.2.2 --- MCPResultPlus.m 22 Aug 2002 21:02:45 -0000 1.1.2.3 *************** *** 65,69 **** - (NSArray *) fetchColWithName:(NSString *) aColName /*" ! The same as #{fetchColAtIndex:}, but the choice of the column is done by it's field name. Indeed it is just a wrapper to #{fetchColAtIndex}. "*/ { --- 65,69 ---- - (NSArray *) fetchColWithName:(NSString *) aColName /*" ! The same as !{fetchColAtIndex:}, but the choice of the column is done by it's field name. Indeed it is just a wrapper to !{fetchColAtIndex}. "*/ { *************** *** 90,100 **** Returns the complete result table in a 2D object, which type depends on aType: ! - MCPTypeArray : a NSArray of rows as NSArray, ! - MCPTypeDictionary : a NSArray of rows as NSDictionary, ! - MCPTypeFlippedArray : a NSArray of columns (as NSArray), ! - MCPTypeFlippedDictionary : a NSDictionary of columns (as NSArray) In any case the read position is restored at the end of the call (hence a fetchRow will get the same row wether this method is called before it or not). --- 90,100 ---- Returns the complete result table in a 2D object, which type depends on aType: ! - !{MCPTypeArray} : a NSArray of rows as NSArray, ! - !{MCPTypeDictionary} : a NSArray of rows as NSDictionary, ! - !{MCPTypeFlippedArray} : a NSArray of columns (as NSArray), ! - !{MCPTypeFlippedDictionary} : a NSDictionary of columns (as NSArray) In any case the read position is restored at the end of the call (hence a fetchRow will get the same row wether this method is called before it or not). Index: MCPFastQueries.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPFastQueries.m,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** MCPFastQueries.m 12 Jun 2002 16:20:38 -0000 1.1.2.3 --- MCPFastQueries.m 22 Aug 2002 21:02:45 -0000 1.1.2.4 *************** *** 48,54 **** - (my_ulonglong) updateQuery:(NSString *) aQuery /*" ! Send the query aQuery to the server and retrieve the number of affected rows (should work with #{update}, #{delete}, #{insert} and #{select} type of queries). ! NB: This can also be used with a #{select} query if you are only interested in the number of row complying with the query; you'll get no chance to get the result from the query, except by sending the query again (with #{queryString:}) "*/ { --- 48,54 ---- - (my_ulonglong) updateQuery:(NSString *) aQuery /*" ! Send the query aQuery to the server and retrieve the number of affected rows (should work with !{update}, !{delete}, !{insert} and !{select} type of queries). ! NB: This can also be used with a !{select} query if you are only interested in the number of row complying with the query; you'll get no chance to get the result from the query, except by sending the query again (with !{queryString:}) "*/ { *************** *** 60,64 **** - (id) getFirstFieldFromQuery:(NSString *) aQuery /*" ! Get the first field of the first row of the result from the query (aQuery). "*/ { --- 60,64 ---- - (id) getFirstFieldFromQuery:(NSString *) aQuery /*" ! Get the first field of the first row of the result from the query (aQuery). Should return nil if no object at all are selected. "*/ { *************** *** 80,84 **** - (id) getAllRowsFromQuery:(NSString *) aQuery asType:(MCPReturnType) aType /*" ! Get a bidimensional table of the whole rows of the result from the query aQuery. The type of the result is choosen by aType, it can be (MCPTypeArray, MCPTypeDictionary, MCPTypeFlippedArray & MCPTypeFlippedDictionary). Description of the types can be found in method #{fetch2DResultAsType:}. "*/ { --- 80,84 ---- - (id) getAllRowsFromQuery:(NSString *) aQuery asType:(MCPReturnType) aType /*" ! Get a bidimensional table of the whole rows of the result from the query aQuery. The type of the result is choosen by aType, it can be (MCPTypeArray, MCPTypeDictionary, MCPTypeFlippedArray & MCPTypeFlippedDictionary). Description of the types can be found in method !{fetch2DResultAsType:}. "*/ { |
From: Serge C. <ser...@us...> - 2002-08-22 20:44:40
|
Update of /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj In directory usw-pr-cvs1:/tmp/cvs-serv21252/SMySQL.pbproj Modified Files: cohen.pbxuser Log Message: Checkin, should correct the null field problem. Serge Cohen; MySQL Cocoa Project 2002-08-22. Index: cohen.pbxuser =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj/cohen.pbxuser,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** cohen.pbxuser 15 May 2002 11:10:02 -0000 1.13 --- cohen.pbxuser 22 Aug 2002 20:44:35 -0000 1.14 *************** *** 3,7 **** 0867D690FE84028FC02AAC07 = { activeBuildStyle = F51A62D4022D7B3301952E7A; ! activeTarget = F51A62D7022D7C2A01952E7A; addToTargets = ( F51A62D7022D7C2A01952E7A, --- 3,7 ---- 0867D690FE84028FC02AAC07 = { activeBuildStyle = F51A62D4022D7B3301952E7A; ! activeTarget = 0867D69CFE84028FC02AAC07; addToTargets = ( F51A62D7022D7C2A01952E7A, *************** *** 16,23 **** Frame = "{{0, 23}, {971, 624}}"; Split0 = { - ActiveTab = 2; Frame = "{{186, 0}, {785, 624}}"; Split0 = { ! Frame = "{{0, 216}, {785, 408}}"; }; SplitCount = 1; --- 16,22 ---- Frame = "{{0, 23}, {971, 624}}"; Split0 = { Frame = "{{186, 0}, {785, 624}}"; Split0 = { ! Frame = "{{0, 24}, {785, 600}}"; }; SplitCount = 1; *************** *** 92,95 **** --- 91,95 ---- TabCount = 5; }; + WindowLocation = "{34, 32}"; }; }; |
From: Serge C. <ser...@us...> - 2002-07-23 14:56:46
|
Update of /cvsroot/mysql-cocoa/SMySQL In directory usw-pr-cvs1:/tmp/cvs-serv7923 Modified Files: Tag: version-2 MCPConnection.h MCPConnection.m MCPResult.h MCPResult.m Log Message: Corrected version-2 for NULL field... should work now. Added the proper handling of year 0000 (default year for year out of ange from MySQL). Some line to log any thing to a file, commented out in the CVS tree. Serge Cohen; MySQL-Cocoa project 2002. Index: MCPConnection.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPConnection.h,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** MCPConnection.h 3 Jun 2002 13:39:24 -0000 1.1.2.4 --- MCPConnection.h 23 Jul 2002 14:56:43 -0000 1.1.2.5 *************** *** 138,140 **** --- 138,145 ---- - (NSString *) stringWithCString:(const char *) theCString; + /*" + Text data convertion to string + "*/ + - (NSString *) stringWithText:(NSData *) theTextData; + @end Index: MCPConnection.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPConnection.m,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -C2 -d -r1.1.2.6 -r1.1.2.7 *** MCPConnection.m 12 Jun 2002 16:20:38 -0000 1.1.2.6 --- MCPConnection.m 23 Jul 2002 14:56:43 -0000 1.1.2.7 *************** *** 32,35 **** --- 32,38 ---- const unsigned int kMCPConnection_Not_Inited = 1000; + // For debugging: + //static FILE *MCPConnectionLogFile; + @implementation MCPConnection *************** *** 117,120 **** --- 120,129 ---- [self setVersion:020000]; // Ma.Mi.Re -> MaMiRe } + + // For debugging: + /* + MCPConnectionLogFile = fopen("MCPConnection_debug.txt","a"); + NSLog(@"MCPConnectionLogFile = %p\n", MCPConnectionLogFile); + */ return; } *************** *** 271,274 **** --- 280,288 ---- } mEncoding = [MCPConnection encodingForMySQLEncoding:mysql_character_set_name(mConnection)]; + /* + NSLog (@"Default encoding is %@\n", [NSString localizedNameOfStringEncoding:[NSString defaultCStringEncoding]]); + NSLog (@"MySQL encoding is %@\n", [NSString localizedNameOfStringEncoding:mEncoding]); + fprintf(MCPConnectionLogFile,"MySQLEncoding : %s\n", (const char *)[[NSString localizedNameOfStringEncoding:mEncoding] cString]); + */ return mConnected = YES; } *************** *** 386,390 **** /*" Takes a query string and return an MCPResult object holding the result of the query. ! The returned MCPResult is not retained, the client is responsible for that (it's autoreleased before being returned). If no field are present in the result (like in an insert query), will return nil (!{difference from previous version implementation}). Note that if you want to use this method with binary data (in the query), you should use #{prepareBinaryData:} to include the binary data in the query string. Also if you want to include in your query a string containing any special character (\, ', " ...) then you should use #{prepareString}. --- 400,404 ---- /*" Takes a query string and return an MCPResult object holding the result of the query. ! The returned MCPResult is not retained, the client is responsible for that (it's autoreleased before being returned). If no field are present in the result (like in an insert query), will return nil (!{difference from previous version implementation}). Though, if their is at least one field the result will be non nil (even if no row are selected). Note that if you want to use this method with binary data (in the query), you should use #{prepareBinaryData:} to include the binary data in the query string. Also if you want to include in your query a string containing any special character (\, ', " ...) then you should use #{prepareString}. *************** *** 394,398 **** --- 408,432 ---- const char *theCQuery = [self cStringFromString:query]; int theQueryCode; + // Temp for debugging: + /* + NSMutableData *theDefCQuery = [NSMutableData dataWithData:[query dataUsingEncoding:[NSString defaultCStringEncoding] allowLossyConversion:YES]]; + NSMutableData *theIso1CQuery = [NSMutableData dataWithData:[query dataUsingEncoding:NSISOLatin1StringEncoding allowLossyConversion:YES]]; + const char *theDCQuery, *theICQuery; + [theDefCQuery increaseLengthBy:1]; + [theIso1CQuery increaseLengthBy:1]; + theDCQuery = [theDefCQuery bytes]; + theICQuery = [theIso1CQuery bytes]; + */ + // NSLog (@"In queryString, query is : %s -in ObjC : %@-\n", theCQuery, query); + /* + fprintf(MCPConnectionLogFile,"C string (MySQL enco.) : "); + fwrite((const void *)theCQuery, strlen(theCQuery), 1, MCPConnectionLogFile); + fprintf(MCPConnectionLogFile,"\nC string (default enco.) : "); + fwrite((const void *)theDCQuery, strlen(theDCQuery), 1, MCPConnectionLogFile); + fprintf(MCPConnectionLogFile,"\nC string (iso1 enco.) : "); + fwrite((const void *)theICQuery, strlen(theICQuery), 1, MCPConnectionLogFile); + fprintf(MCPConnectionLogFile,"\n"); + */ if ((theQueryCode = mysql_query(mConnection, theCQuery)) == NULL) { if (mysql_field_count(mConnection) != 0) { *************** *** 753,756 **** --- 787,809 ---- return theString; } + + + - (NSString *) stringWithText:(NSData *) theTextData + /*" + Use the string encoding to convert the returned NSData to a string (for a Text field) + "*/ + { + NSString * theString; + + if (theTextData == nil) { + return nil; + } + theString = [[NSString alloc] initWithData:theTextData encoding:mEncoding]; + if (theString) { + [theString autorelease]; + } + return theString; + } + @end Index: MCPResult.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPResult.h,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** MCPResult.h 3 Jun 2002 13:39:24 -0000 1.1.2.4 --- MCPResult.h 23 Jul 2002 14:56:43 -0000 1.1.2.5 *************** *** 82,85 **** --- 82,90 ---- /*" + Text data convertion to string + "*/ + - (NSString *) stringWithText:(NSData *) theTextData; + + /*" Utility method "*/ *************** *** 93,97 **** /*" ! Private methods, internam use only "*/ - (const char *) cStringFromString:(NSString *) theString; --- 98,102 ---- /*" ! Private methods, internal use only "*/ - (const char *) cStringFromString:(NSString *) theString; Index: MCPResult.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPResult.m,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -C2 -d -r1.1.2.5 -r1.1.2.6 *** MCPResult.m 12 Jun 2002 16:20:38 -0000 1.1.2.5 --- MCPResult.m 23 Jul 2002 14:56:43 -0000 1.1.2.6 *************** *** 30,33 **** --- 30,34 ---- #import "MCPResult.h" + NSCalendarDate *MCPYear0000; @implementation MCPResult *************** *** 69,72 **** --- 70,75 ---- if (self = [MCPResult class]) { [self setVersion:020000]; // Ma.Mi.Re -> MaMiRe + MCPYear0000 = [[NSCalendarDate dateWithTimeIntervalSinceReferenceDate:-63146822400.0] retain]; + [MCPYear0000 setCalendarFormat:@"%Y"]; } return; *************** *** 290,293 **** --- 293,304 ---- theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithCString:theData] calendarFormat:@"%Y"]; [theCurrentObj setCalendarFormat:@"%Y"]; + // MySQL is not able to save years before 1900, and then gives a column of 0000, unfortunately, NSCalendarDate + // doesn't accept the string @"0000" in the method datewithString: calendarFormat:@"%Y"... + if (! theCurrentObj) { + theCurrentObj = MCPYear0000; + } + // Debugging + // NSLog(@"The Yeear is : %@, the field is %s\n", theCurrentObj, theData); + // End break; case FIELD_TYPE_VAR_STRING: *************** *** 320,323 **** --- 331,338 ---- } free(theData); + // Some of the creators return nil object... + if (theCurrentObj == nil) { + theCurrentObj = [NSNull null]; + } } switch (aType) { *************** *** 617,621 **** Return YES if the field (by name) with the given index is a BLOB. It should be used to discriminates between BLOBs and TEXTs. ! #{NOT YET IMPLEMENTED}, return YES for both BLOBs and TEXTs... "*/ { --- 632,636 ---- Return YES if the field (by name) with the given index is a BLOB. It should be used to discriminates between BLOBs and TEXTs. ! !{NOT YET IMPLEMENTED}, return YES for both BLOBs and TEXTs... "*/ { *************** *** 653,656 **** --- 668,689 ---- } return theRet; + } + + + - (NSString *) stringWithText:(NSData *) theTextData + /*" + Use the string encoding to convert the returned NSData to a string (for a Text field) + "*/ + { + NSString * theString; + + if (theTextData == nil) { + return nil; + } + theString = [[NSString alloc] initWithData:theTextData encoding:mEncoding]; + if (theString) { + [theString autorelease]; + } + return theString; } |
From: Serge C. <ser...@us...> - 2002-07-23 14:56:46
|
Update of /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj In directory usw-pr-cvs1:/tmp/cvs-serv7923/SMySQL.pbproj Modified Files: Tag: version-2 cohen.pbxuser Log Message: Corrected version-2 for NULL field... should work now. Added the proper handling of year 0000 (default year for year out of ange from MySQL). Some line to log any thing to a file, commented out in the CVS tree. Serge Cohen; MySQL-Cocoa project 2002. Index: cohen.pbxuser =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj/cohen.pbxuser,v retrieving revision 1.13.2.6 retrieving revision 1.13.2.7 diff -C2 -d -r1.13.2.6 -r1.13.2.7 *** cohen.pbxuser 12 Jun 2002 16:20:49 -0000 1.13.2.6 --- cohen.pbxuser 23 Jul 2002 14:56:43 -0000 1.13.2.7 *************** *** 2,6 **** { 0867D690FE84028FC02AAC07 = { ! activeBuildStyle = 014CEA440018CDF011CA2923; activeTarget = F5649F0E023FDCA201D04C4B; addToTargets = ( --- 2,6 ---- { 0867D690FE84028FC02AAC07 = { ! activeBuildStyle = F51A62D4022D7B3301952E7A; activeTarget = F5649F0E023FDCA201D04C4B; addToTargets = ( *************** *** 13,25 **** perUserDictionary = { PBXWorkspaceConfiguration = { ! ContentSize = "{970, 674}"; LeftSlideOut = { ActiveTab = 3; ! Frame = "{{0, 23}, {970, 651}}"; Split0 = { ActiveTab = 2; ! Frame = "{{224, 0}, {746, 651}}"; Split0 = { ! Frame = "{{0, 216}, {746, 435}}"; }; SplitCount = 1; --- 13,25 ---- perUserDictionary = { PBXWorkspaceConfiguration = { ! ContentSize = "{1019, 656}"; LeftSlideOut = { ActiveTab = 3; ! Frame = "{{0, 23}, {1019, 633}}"; Split0 = { ActiveTab = 2; ! Frame = "{{224, 0}, {795, 633}}"; Split0 = { ! Frame = "{{0, 216}, {795, 417}}"; }; SplitCount = 1; *************** *** 58,67 **** }; Tab2 = { ! BuildMessageFrame = "{{0, 0}, {748, 94}}"; ! BuildTranscriptFrame = "{{0, 103}, {748, 91}}"; ! Frame = "{{0, 0}, {746, 192}}"; }; Tab3 = { ! Frame = "{{0, 0}, {792, 295}}"; }; TabCount = 4; --- 58,67 ---- }; Tab2 = { ! BuildMessageFrame = "{{0, 0}, {797, 94}}"; ! BuildTranscriptFrame = "{{0, 103}, {797, 91}}"; ! Frame = "{{0, 0}, {795, 192}}"; }; Tab3 = { ! Frame = "{{0, 0}, {720, 295}}"; }; TabCount = 4; *************** *** 69,73 **** SplitCount = 1; Tab0 = { ! Frame = "{{0, 0}, {275, 651}}"; }; Tab1 = { --- 69,73 ---- SplitCount = 1; Tab0 = { ! Frame = "{{0, 0}, {275, 633}}"; }; Tab1 = { *************** *** 81,90 **** }; Tab3 = { ! Frame = "{{0, 0}, {200, 651}}"; Split0 = { ! Frame = "{{0, 0}, {200, 312}}"; }; Split1 = { ! Frame = "{{0, 321}, {200, 330}}"; }; SplitCount = 2; --- 81,90 ---- }; Tab3 = { ! Frame = "{{0, 0}, {200, 633}}"; Split0 = { ! Frame = "{{0, 0}, {200, 303}}"; }; Split1 = { ! Frame = "{{0, 312}, {200, 321}}"; }; SplitCount = 2; *************** *** 95,99 **** TabCount = 5; }; ! WindowLocation = "{0, 10}"; }; }; --- 95,99 ---- TabCount = 5; }; ! WindowLocation = "{0, 28}"; }; }; |
From: Serge C. <ser...@us...> - 2002-06-12 16:20:53
|
Update of /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj In directory usw-pr-cvs1:/tmp/cvs-serv24245 Modified Files: Tag: version-2 project.pbxproj cohen.pbxuser Log Message: Fixed a bug: a project header was not set to public (MCPFastQueries). Added the method updateQuery: to the (MCPFastQueries) category Few fixes. Serge Cohen; MySQL Cocoa project, 2002-06-12.... Index: project.pbxproj =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj/project.pbxproj,v retrieving revision 1.13.2.5 retrieving revision 1.13.2.6 diff -C2 -d -r1.13.2.5 -r1.13.2.6 *** project.pbxproj 4 Jun 2002 07:57:56 -0000 1.13.2.5 --- project.pbxproj 12 Jun 2002 16:20:49 -0000 1.13.2.6 *************** *** 2265,2268 **** --- 2265,2271 ---- isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Public, + ); }; }; *************** *** 2277,2280 **** --- 2280,2286 ---- isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Public, + ); }; }; *************** *** 2289,2292 **** --- 2295,2301 ---- isa = PBXBuildFile; settings = { + ATTRIBUTES = ( + Public, + ); }; }; Index: cohen.pbxuser =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj/cohen.pbxuser,v retrieving revision 1.13.2.5 retrieving revision 1.13.2.6 diff -C2 -d -r1.13.2.5 -r1.13.2.6 *** cohen.pbxuser 4 Jun 2002 07:57:56 -0000 1.13.2.5 --- cohen.pbxuser 12 Jun 2002 16:20:49 -0000 1.13.2.6 *************** *** 15,25 **** ContentSize = "{970, 674}"; LeftSlideOut = { ! ActiveTab = 0; Frame = "{{0, 23}, {970, 651}}"; Split0 = { ActiveTab = 2; ! Frame = "{{299, 0}, {671, 651}}"; Split0 = { ! Frame = "{{0, 216}, {671, 435}}"; }; SplitCount = 1; --- 15,25 ---- ContentSize = "{970, 674}"; LeftSlideOut = { ! ActiveTab = 3; Frame = "{{0, 23}, {970, 651}}"; Split0 = { ActiveTab = 2; ! Frame = "{{224, 0}, {746, 651}}"; Split0 = { ! Frame = "{{0, 216}, {746, 435}}"; }; SplitCount = 1; *************** *** 58,64 **** }; Tab2 = { ! BuildMessageFrame = "{{0, 0}, {673, 44}}"; ! BuildTranscriptFrame = "{{0, 53}, {673, 141}}"; ! Frame = "{{0, 0}, {671, 192}}"; }; Tab3 = { --- 58,64 ---- }; Tab2 = { ! BuildMessageFrame = "{{0, 0}, {748, 94}}"; ! BuildTranscriptFrame = "{{0, 103}, {748, 91}}"; ! Frame = "{{0, 0}, {746, 192}}"; }; Tab3 = { |
From: Serge C. <ser...@us...> - 2002-06-12 16:20:43
|
Update of /cvsroot/mysql-cocoa/SMySQL In directory usw-pr-cvs1:/tmp/cvs-serv24173 Modified Files: Tag: version-2 SMySQL.h MCPConnection.m MCPResult.m MCPFastQueries.h MCPFastQueries.m Log Message: Fixed a bug: a project header was not set to public (MCPFastQueries). Added the method updateQuery: to the (MCPFastQueries) category Few fixes. Serge Cohen; MySQL Cocoa project, 2002-06-12. Index: SMySQL.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQL.h,v retrieving revision 1.2.2.4 retrieving revision 1.2.2.5 diff -C2 -d -r1.2.2.4 -r1.2.2.5 *** SMySQL.h 4 Jun 2002 07:57:44 -0000 1.2.2.4 --- SMySQL.h 12 Jun 2002 16:20:38 -0000 1.2.2.5 *************** *** 33,36 **** --- 33,37 ---- #import <SMySQL/MCPConnection.h> #import <SMySQL/MCPResultPlus.h> + #import <SMySQL/MCPFastQueries.h> #import "mysql.h" //#import <SMySQL/mysql.h> Index: MCPConnection.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPConnection.m,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -C2 -d -r1.1.2.5 -r1.1.2.6 *** MCPConnection.m 4 Jun 2002 07:57:44 -0000 1.1.2.5 --- MCPConnection.m 12 Jun 2002 16:20:38 -0000 1.1.2.6 *************** *** 386,391 **** /*" Takes a query string and return an MCPResult object holding the result of the query. ! The returned MCPResult is not retained, the client is responsible for that (it's autoreleased before being returned) ! Note that if you want to use this method with binary data (in the query), you should use !{prepareBinaryData:} to include the binary data in the query string. "*/ { --- 386,392 ---- /*" Takes a query string and return an MCPResult object holding the result of the query. ! The returned MCPResult is not retained, the client is responsible for that (it's autoreleased before being returned). If no field are present in the result (like in an insert query), will return nil (!{difference from previous version implementation}). ! ! Note that if you want to use this method with binary data (in the query), you should use #{prepareBinaryData:} to include the binary data in the query string. Also if you want to include in your query a string containing any special character (\, ', " ...) then you should use #{prepareString}. "*/ { *************** *** 400,404 **** else { // NSLog (@"Query worked but gives no output\n"); ! [theResult init]; } } --- 401,406 ---- else { // NSLog (@"Query worked but gives no output\n"); ! // [theResult init]; ! return nil; } } Index: MCPResult.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPResult.m,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** MCPResult.m 3 Jun 2002 13:39:24 -0000 1.1.2.4 --- MCPResult.m 12 Jun 2002 16:20:38 -0000 1.1.2.5 *************** *** 274,280 **** --- 274,282 ---- // Here it will crash if it's not default presentation : TIMESTAMP(14) theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y%m%d%H%M%S"]; + [theCurrentObj setCalendarFormat:@"%Y-%m-%d %H:%M:%S"]; break; case FIELD_TYPE_DATE: theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d"]; + [theCurrentObj setCalendarFormat:@"%Y-%m-%d"]; break; case FIELD_TYPE_TIME: *************** *** 282,289 **** theCurrentObj = [NSString stringWithUTF8String:theData]; case FIELD_TYPE_DATETIME: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d %H:%M:%S"]; break; case FIELD_TYPE_YEAR: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y"]; break; case FIELD_TYPE_VAR_STRING: --- 284,293 ---- theCurrentObj = [NSString stringWithUTF8String:theData]; case FIELD_TYPE_DATETIME: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithCString:theData] calendarFormat:@"%Y-%m-%d %H:%M:%S"]; ! [theCurrentObj setCalendarFormat:@"%Y-%m-%d %H:%M:%S"]; break; case FIELD_TYPE_YEAR: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithCString:theData] calendarFormat:@"%Y"]; ! [theCurrentObj setCalendarFormat:@"%Y"]; break; case FIELD_TYPE_VAR_STRING: Index: MCPFastQueries.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPFastQueries.h,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** MCPFastQueries.h 4 Jun 2002 07:57:44 -0000 1.1.2.2 --- MCPFastQueries.h 12 Jun 2002 16:20:38 -0000 1.1.2.3 *************** *** 33,36 **** --- 33,37 ---- "*/ - (my_ulonglong) insertQuery:(NSString *) aQuery; + - (my_ulonglong) updateQuery:(NSString *) aQuery; Index: MCPFastQueries.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPFastQueries.m,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** MCPFastQueries.m 4 Jun 2002 07:57:44 -0000 1.1.2.2 --- MCPFastQueries.m 12 Jun 2002 16:20:38 -0000 1.1.2.3 *************** *** 37,41 **** - (my_ulonglong) insertQuery:(NSString *) aQuery /*" ! Send tyhe query aQuery to the server and retrieve the row id if the table have a autoincrement column. Returns 0 if no have been inserted "*/ --- 37,41 ---- - (my_ulonglong) insertQuery:(NSString *) aQuery /*" ! Send the query aQuery to the server and retrieve the row id if the table have a autoincrement column. Returns 0 if no have been inserted "*/ *************** *** 43,46 **** --- 43,58 ---- [self queryString:aQuery]; return [self insertId]; + } + + + - (my_ulonglong) updateQuery:(NSString *) aQuery + /*" + Send the query aQuery to the server and retrieve the number of affected rows (should work with #{update}, #{delete}, #{insert} and #{select} type of queries). + + NB: This can also be used with a #{select} query if you are only interested in the number of row complying with the query; you'll get no chance to get the result from the query, except by sending the query again (with #{queryString:}) + "*/ + { + [self queryString:aQuery]; + return [self affectedRows]; } |
From: Serge C. <ser...@us...> - 2002-06-04 07:58:00
|
Update of /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj In directory usw-pr-cvs1:/tmp/cvs-serv28698 Modified Files: Tag: version-2 project.pbxproj cohen.pbxuser Log Message: Added a insertQuery method to MCPFastQueries. Serge Cohen; MySQL Cocoa project, 2002-06-04.... Index: project.pbxproj =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj/project.pbxproj,v retrieving revision 1.13.2.4 retrieving revision 1.13.2.5 diff -C2 -d -r1.13.2.4 -r1.13.2.5 *** project.pbxproj 3 Jun 2002 14:12:03 -0000 1.13.2.4 --- project.pbxproj 4 Jun 2002 07:57:56 -0000 1.13.2.5 *************** *** 2011,2014 **** --- 2011,2015 ---- F5649F12023FDCA201D04C4B, F5649F13023FDCA201D04C4B, + F5A0E64B02AC19CB01D99F77, ); buildSettings = { *************** *** 2406,2409 **** --- 2407,2423 ---- isa = PBXRezBuildPhase; name = "ResourceManager Resources"; + }; + F5A0E64B02AC19CB01D99F77 = { + buildActionMask = 2147483647; + files = ( + ); + generatedFileNames = ( + ); + isa = PBXShellScriptBuildPhase; + name = "Shell Script"; + neededFileNames = ( + ); + shellPath = /bin/sh; + shellScript = "MKDIRS=\"mkdir -p\"\nAUTODOC=/usr/local/bin/autodoc\nAUTODOC_FLAGS=\"-copydocs -timestamp -allclasses\"\nAUTODOC_FORMAT=html\nAUTODOC_LANGUAGE=English\nexport AD_COPYRIGHT=\"MySQL Cocoa Project\"\n\n# If autodoc is not installed, we quit without any error\ntest -x $AUTODOC || exit 0\n\nPUBLIC_DOC_INSTALLDIR=\"$SYMROOT/$PRODUCT_NAME.framework/Resources/$AUTODOC_LANGUAGE.lproj/Documentation\"\n\n# We need to write down file names here\nAUTODOC_FILES=\"MCPConnection.h MCPResult.h MCPNull.h MCPResultPlus.h MCPFastQueries.h\"\nAUTODOC_DOCDIR=\"$PUBLIC_DOC_INSTALLDIR\"\n\nOTHER_AUTODOC_FLAGS=\"-typedirs -allclasses -combine -force -nosingles\"\n\nALL_AUTODOC_FLAGS=\"$AUTODOC_FLAGS $OTHER_AUTODOC_FLAGS\"\n\n$MKDIRS $PUBLIC_DOC_INSTALLDIR\n$AUTODOC $ALL_AUTODOC_FLAGS -format $AUTODOC_FORMAT -dest $AUTODOC_DOCDIR $AUTODOC_FILES\n"; }; F5C0D59002884F280172C088 = { Index: cohen.pbxuser =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj/cohen.pbxuser,v retrieving revision 1.13.2.4 retrieving revision 1.13.2.5 diff -C2 -d -r1.13.2.4 -r1.13.2.5 *** cohen.pbxuser 3 Jun 2002 14:12:03 -0000 1.13.2.4 --- cohen.pbxuser 4 Jun 2002 07:57:56 -0000 1.13.2.5 *************** *** 3,7 **** 0867D690FE84028FC02AAC07 = { activeBuildStyle = 014CEA440018CDF011CA2923; ! activeTarget = 0867D69CFE84028FC02AAC07; addToTargets = ( 0867D69CFE84028FC02AAC07, --- 3,7 ---- 0867D690FE84028FC02AAC07 = { activeBuildStyle = 014CEA440018CDF011CA2923; ! activeTarget = F5649F0E023FDCA201D04C4B; addToTargets = ( 0867D69CFE84028FC02AAC07, *************** *** 13,25 **** perUserDictionary = { PBXWorkspaceConfiguration = { ! ContentSize = "{1024, 674}"; LeftSlideOut = { ActiveTab = 0; ! Frame = "{{0, 23}, {1024, 651}}"; Split0 = { ActiveTab = 2; ! Frame = "{{232, 0}, {792, 651}}"; Split0 = { ! Frame = "{{0, 216}, {792, 435}}"; }; SplitCount = 1; --- 13,25 ---- perUserDictionary = { PBXWorkspaceConfiguration = { ! ContentSize = "{970, 674}"; LeftSlideOut = { ActiveTab = 0; ! Frame = "{{0, 23}, {970, 651}}"; Split0 = { ActiveTab = 2; ! Frame = "{{299, 0}, {671, 651}}"; Split0 = { ! Frame = "{{0, 216}, {671, 435}}"; }; SplitCount = 1; *************** *** 51,64 **** }; Tab1 = { ! Frame = "{{0, 0}, {792, 208}}"; LauncherConfigVersion = 3; Runner = { ! Frame = "{{0, 0}, {792, 208}}"; }; }; Tab2 = { ! BuildMessageFrame = "{{0, 0}, {794, 95}}"; ! BuildTranscriptFrame = "{{0, 104}, {794, 90}}"; ! Frame = "{{0, 0}, {792, 192}}"; }; Tab3 = { --- 51,64 ---- }; Tab1 = { ! Frame = "{{0, 0}, {746, 208}}"; LauncherConfigVersion = 3; Runner = { ! Frame = "{{0, 0}, {746, 208}}"; }; }; Tab2 = { ! BuildMessageFrame = "{{0, 0}, {673, 44}}"; ! BuildTranscriptFrame = "{{0, 53}, {673, 141}}"; ! Frame = "{{0, 0}, {671, 192}}"; }; Tab3 = { *************** *** 69,73 **** SplitCount = 1; Tab0 = { ! Frame = "{{0, 0}, {208, 651}}"; }; Tab1 = { --- 69,73 ---- SplitCount = 1; Tab0 = { ! Frame = "{{0, 0}, {275, 651}}"; }; Tab1 = { *************** *** 81,90 **** }; Tab3 = { ! Frame = "{{0, 0}, {200, 550}}"; Split0 = { ! Frame = "{{0, 0}, {200, 263}}"; }; Split1 = { ! Frame = "{{0, 272}, {200, 278}}"; }; SplitCount = 2; --- 81,90 ---- }; Tab3 = { ! Frame = "{{0, 0}, {200, 651}}"; Split0 = { ! Frame = "{{0, 0}, {200, 312}}"; }; Split1 = { ! Frame = "{{0, 321}, {200, 330}}"; }; SplitCount = 2; |
From: Serge C. <ser...@us...> - 2002-06-04 07:57:49
|
Update of /cvsroot/mysql-cocoa/SMySQL In directory usw-pr-cvs1:/tmp/cvs-serv28381 Modified Files: Tag: version-2 TO_DO SMySQL.h MCPConnection.m MCPFastQueries.h MCPFastQueries.m Log Message: Added a insertQuery method to MCPFastQueries. Serge Cohen; MySQL Cocoa project, 2002-06-04. Index: TO_DO =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/TO_DO,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** TO_DO 3 Jun 2002 14:11:51 -0000 1.1.2.3 --- TO_DO 4 Jun 2002 07:57:44 -0000 1.1.2.4 *************** *** 29,30 **** --- 29,31 ---- - (NSArray *) getQuery:(NSString *) query colWithIndex:(unsigned int) aCol; (Getting a single column form the query) - (NSArray *) getQuery:(NSString *) query colWithName:(NSString *) aColName; + -> Ok \ No newline at end of file Index: SMySQL.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQL.h,v retrieving revision 1.2.2.3 retrieving revision 1.2.2.4 diff -C2 -d -r1.2.2.3 -r1.2.2.4 *** SMySQL.h 3 Jun 2002 13:39:24 -0000 1.2.2.3 --- SMySQL.h 4 Jun 2002 07:57:44 -0000 1.2.2.4 *************** *** 32,36 **** #import <SMySQL/MCPResult.h> #import <SMySQL/MCPConnection.h> ! #import <SMySQL/MCPResultsPlus.h> #import "mysql.h" //#import <SMySQL/mysql.h> --- 32,36 ---- #import <SMySQL/MCPResult.h> #import <SMySQL/MCPConnection.h> ! #import <SMySQL/MCPResultPlus.h> #import "mysql.h" //#import <SMySQL/mysql.h> Index: MCPConnection.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPConnection.m,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** MCPConnection.m 3 Jun 2002 13:39:24 -0000 1.1.2.4 --- MCPConnection.m 4 Jun 2002 07:57:44 -0000 1.1.2.5 *************** *** 365,372 **** { const char *theCStringBuffer = [self cStringFromString:theString]; ! unsigned int theLength = strlen(theCStringBuffer); ! char *theCEscBuffer = (char *)calloc(sizeof(char),(theLength * 2) + 1); NSString *theReturn; mysql_real_escape_string(mConnection, theCEscBuffer, theCStringBuffer, theLength); theReturn = [self stringWithCString:theCEscBuffer]; --- 365,379 ---- { const char *theCStringBuffer = [self cStringFromString:theString]; ! unsigned int theLength; ! char *theCEscBuffer; NSString *theReturn; + if (theString == nil) { + #pragma warning This is not the best solution, here we loose difference between NULL and empty string. + // In the mean time, no one should call this method on a nil string, the test should be done before by the user of this method. + return @""; + } + theLength = strlen(theCStringBuffer); + theCEscBuffer = (char *)calloc(sizeof(char),(theLength * 2) + 1); mysql_real_escape_string(mConnection, theCEscBuffer, theCStringBuffer, theLength); theReturn = [self stringWithCString:theCEscBuffer]; Index: MCPFastQueries.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPFastQueries.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** MCPFastQueries.h 3 Jun 2002 14:11:51 -0000 1.1.2.1 --- MCPFastQueries.h 4 Jun 2002 07:57:44 -0000 1.1.2.2 *************** *** 29,32 **** --- 29,37 ---- @interface MCPConnection (MCPFastQueries) + /*" + For insert queries, get directly the Id of the newly inserted row + "*/ + - (my_ulonglong) insertQuery:(NSString *) aQuery; + /*" Index: MCPFastQueries.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPFastQueries.m,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** MCPFastQueries.m 3 Jun 2002 14:11:51 -0000 1.1.2.1 --- MCPFastQueries.m 4 Jun 2002 07:57:44 -0000 1.1.2.2 *************** *** 35,38 **** --- 35,48 ---- Basicly this is the place to add methods which are useful, but are just wrappers to the methods of the core (MCPConnection, MCPResult). The purpous being to have a single line call available for current tasks which otherwise would need a couple of lines and object defined. "*/ + - (my_ulonglong) insertQuery:(NSString *) aQuery + /*" + Send tyhe query aQuery to the server and retrieve the row id if the table have a autoincrement column. + Returns 0 if no have been inserted + "*/ + { + [self queryString:aQuery]; + return [self insertId]; + } + - (id) getFirstFieldFromQuery:(NSString *) aQuery |
From: Serge C. <ser...@us...> - 2002-06-03 15:06:01
|
Update of /cvsroot/mysql-cocoa/SMySQL In directory usw-pr-cvs1:/tmp/cvs-serv19203 Modified Files: SMySQLResult.m Log Message: Corrected the NULL Field bug. When a NULL field is encountered a NSNull object is put in the NSArray or NSDictionary. Serge Cohen; MySQL Cocoa project, 2002-06-03. Index: SMySQLResult.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQLResult.m,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SMySQLResult.m 15 May 2002 11:07:30 -0000 1.6 --- SMySQLResult.m 3 Jun 2002 15:05:58 -0000 1.7 *************** *** 213,287 **** id theCurrentObj,theDataObj; char *theData = calloc(sizeof(char),theLengths[i]+1); ! memcpy(theData, theRow[i],theLengths[i]); ! theData[theLengths[i]] = '\0'; ! // NSLog (@"in fetchRowAsDictionary : field type is %d, for column %d", (int)theField[i].type, (int)i); ! switch (theField[i].type) { ! case FIELD_TYPE_TINY: ! case FIELD_TYPE_SHORT: ! case FIELD_TYPE_LONG: ! case FIELD_TYPE_INT24: ! case FIELD_TYPE_LONGLONG: ! theCurrentObj = [NSNumber numberWithLong:atol(theData)]; ! break; ! case FIELD_TYPE_DECIMAL: ! case FIELD_TYPE_FLOAT: ! case FIELD_TYPE_DOUBLE: ! theCurrentObj = [NSNumber numberWithDouble:atof(theData)]; ! break; ! case FIELD_TYPE_TIMESTAMP: // Indeed one should check which format it is (14,12...2) and get the corresponding format string // a switch on theLength[i] would do that... // Here it will crash if it's not default presentation : TIMESTAMP(14) ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y%m%d%H%M%S"]; ! break; ! case FIELD_TYPE_DATE: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d"]; ! break; ! case FIELD_TYPE_TIME: // Pass them back as string for the moment... not TIME object in Cocoa (so far) ! theCurrentObj = [NSString stringWithUTF8String:theData]; ! case FIELD_TYPE_DATETIME: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d %H:%M:%S"]; ! break; ! case FIELD_TYPE_YEAR: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y"]; ! break; ! case FIELD_TYPE_VAR_STRING: ! case FIELD_TYPE_STRING: ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! case FIELD_TYPE_TINY_BLOB: ! case FIELD_TYPE_BLOB: ! case FIELD_TYPE_MEDIUM_BLOB: ! case FIELD_TYPE_LONG_BLOB: ! theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! break; ! case FIELD_TYPE_SET: ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! case FIELD_TYPE_ENUM: ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! case FIELD_TYPE_NULL: ! theCurrentObj = nil; ! break; ! case FIELD_TYPE_NEWDATE: // Don't know what the format for this type is... ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! default: ! NSLog (@"in fetchRowAsDictionary : Unknown type : %d for column %d, send back a NSData object", (int)theField[i].type, (int)i); ! theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! break; } [theDict setObject:theCurrentObj forKey:[mNames objectAtIndex:i]]; --- 213,292 ---- id theCurrentObj,theDataObj; char *theData = calloc(sizeof(char),theLengths[i]+1); ! if (theRow[i] == NULL) { ! theCurrentObj = [NSNull null]; ! } ! else { ! memcpy(theData, theRow[i],theLengths[i]); ! theData[theLengths[i]] = '\0'; ! // NSLog (@"in fetchRowAsDictionary : field type is %d, for column %d", (int)theField[i].type, (int)i); ! switch (theField[i].type) { ! case FIELD_TYPE_TINY: ! case FIELD_TYPE_SHORT: ! case FIELD_TYPE_LONG: ! case FIELD_TYPE_INT24: ! case FIELD_TYPE_LONGLONG: ! theCurrentObj = [NSNumber numberWithLong:atol(theData)]; ! break; ! case FIELD_TYPE_DECIMAL: ! case FIELD_TYPE_FLOAT: ! case FIELD_TYPE_DOUBLE: ! theCurrentObj = [NSNumber numberWithDouble:atof(theData)]; ! break; ! case FIELD_TYPE_TIMESTAMP: // Indeed one should check which format it is (14,12...2) and get the corresponding format string // a switch on theLength[i] would do that... // Here it will crash if it's not default presentation : TIMESTAMP(14) ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y%m%d%H%M%S"]; ! break; ! case FIELD_TYPE_DATE: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d"]; ! break; ! case FIELD_TYPE_TIME: // Pass them back as string for the moment... not TIME object in Cocoa (so far) ! theCurrentObj = [NSString stringWithUTF8String:theData]; ! case FIELD_TYPE_DATETIME: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d %H:%M:%S"]; ! break; ! case FIELD_TYPE_YEAR: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y"]; ! break; ! case FIELD_TYPE_VAR_STRING: ! case FIELD_TYPE_STRING: ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! case FIELD_TYPE_TINY_BLOB: ! case FIELD_TYPE_BLOB: ! case FIELD_TYPE_MEDIUM_BLOB: ! case FIELD_TYPE_LONG_BLOB: ! theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! break; ! case FIELD_TYPE_SET: ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! case FIELD_TYPE_ENUM: ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! case FIELD_TYPE_NULL: ! theCurrentObj = nil; ! break; ! case FIELD_TYPE_NEWDATE: // Don't know what the format for this type is... ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! default: ! NSLog (@"in fetchRowAsDictionary : Unknown type : %d for column %d, send back a NSData object", (int)theField[i].type, (int)i); ! theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! break; ! } } [theDict setObject:theCurrentObj forKey:[mNames objectAtIndex:i]]; *************** *** 324,399 **** id theCurrentObj,theDataObj; char *theData = calloc(sizeof(char),theLengths[i]+1); ! memcpy(theData, theRow[i],theLengths[i]); ! theData[theLengths[i]] = '\0'; ! // NSLog (@"in fetchRowAsArray : field type is %d, for column %d", (int)theField[i].type, (int)i); ! switch (theField[i].type) { ! case FIELD_TYPE_TINY: ! case FIELD_TYPE_SHORT: ! case FIELD_TYPE_LONG: ! case FIELD_TYPE_INT24: ! case FIELD_TYPE_LONGLONG: ! theCurrentObj = [NSNumber numberWithLong:atol(theData)]; ! break; ! case FIELD_TYPE_DECIMAL: ! case FIELD_TYPE_FLOAT: ! case FIELD_TYPE_DOUBLE: ! theCurrentObj = [NSNumber numberWithDouble:atof(theData)]; ! break; ! case FIELD_TYPE_TIMESTAMP: // Indeed one should check which format it is (14,12...2) and get the corresponding format string // a switch on theLength[i] would do that... // Here it will crash if it's not default presentation : TIMESTAMP(14) ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y%m%d%H%M%S"]; ! break; ! case FIELD_TYPE_DATE: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d"]; ! break; ! case FIELD_TYPE_TIME: // Pass them back as string for the moment... not TIME object in Cocoa (so far) ! theCurrentObj = [NSString stringWithUTF8String:theData]; ! case FIELD_TYPE_DATETIME: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d %H:%M:%S"]; ! break; ! case FIELD_TYPE_YEAR: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y"]; ! break; ! case FIELD_TYPE_VAR_STRING: ! case FIELD_TYPE_STRING: ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! case FIELD_TYPE_TINY_BLOB: ! case FIELD_TYPE_BLOB: ! case FIELD_TYPE_MEDIUM_BLOB: ! case FIELD_TYPE_LONG_BLOB: ! theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! break; ! case FIELD_TYPE_SET: ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! case FIELD_TYPE_ENUM: ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! case FIELD_TYPE_NULL: ! theCurrentObj = nil; ! break; ! case FIELD_TYPE_NEWDATE: // Don't know what the format for this type is... ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! default: ! NSLog (@"in fetchRowAsArray : Unknown type : %d for column %d, send back a NSData object", (int)theField[i].type, (int)i); ! theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! break; } [theArray addObject:theCurrentObj]; --- 329,409 ---- id theCurrentObj,theDataObj; char *theData = calloc(sizeof(char),theLengths[i]+1); ! if (theRow[i] == NULL) { ! theCurrentObj = [NSNull null]; ! } ! else { ! memcpy(theData, theRow[i],theLengths[i]); ! theData[theLengths[i]] = '\0'; ! // NSLog (@"in fetchRowAsArray : field type is %d, for column %d", (int)theField[i].type, (int)i); ! switch (theField[i].type) { ! case FIELD_TYPE_TINY: ! case FIELD_TYPE_SHORT: ! case FIELD_TYPE_LONG: ! case FIELD_TYPE_INT24: ! case FIELD_TYPE_LONGLONG: ! theCurrentObj = [NSNumber numberWithLong:atol(theData)]; ! break; ! case FIELD_TYPE_DECIMAL: ! case FIELD_TYPE_FLOAT: ! case FIELD_TYPE_DOUBLE: ! theCurrentObj = [NSNumber numberWithDouble:atof(theData)]; ! break; ! case FIELD_TYPE_TIMESTAMP: // Indeed one should check which format it is (14,12...2) and get the corresponding format string // a switch on theLength[i] would do that... // Here it will crash if it's not default presentation : TIMESTAMP(14) ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y%m%d%H%M%S"]; ! break; ! case FIELD_TYPE_DATE: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d"]; ! break; ! case FIELD_TYPE_TIME: // Pass them back as string for the moment... not TIME object in Cocoa (so far) ! theCurrentObj = [NSString stringWithUTF8String:theData]; ! case FIELD_TYPE_DATETIME: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d %H:%M:%S"]; ! break; ! case FIELD_TYPE_YEAR: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y"]; ! break; ! case FIELD_TYPE_VAR_STRING: ! case FIELD_TYPE_STRING: ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! case FIELD_TYPE_TINY_BLOB: ! case FIELD_TYPE_BLOB: ! case FIELD_TYPE_MEDIUM_BLOB: ! case FIELD_TYPE_LONG_BLOB: ! theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! break; ! case FIELD_TYPE_SET: ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! case FIELD_TYPE_ENUM: ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! case FIELD_TYPE_NULL: ! theCurrentObj = nil; ! break; ! case FIELD_TYPE_NEWDATE: // Don't know what the format for this type is... ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! default: ! NSLog (@"in fetchRowAsArray : Unknown type : %d for column %d, send back a NSData object", (int)theField[i].type, (int)i); ! theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! break; ! } } [theArray addObject:theCurrentObj]; |
From: Serge C. <ser...@us...> - 2002-06-03 14:12:08
|
Update of /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj In directory usw-pr-cvs1:/tmp/cvs-serv568 Modified Files: Tag: version-2 project.pbxproj cohen.pbxuser Log Message: Added the category MCPFastQueries to MCPConnection. Serge Cohen; MySQL Cocoa project, 2002-06-03.... Index: project.pbxproj =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj/project.pbxproj,v retrieving revision 1.13.2.3 retrieving revision 1.13.2.4 diff -C2 -d -r1.13.2.3 -r1.13.2.4 *** project.pbxproj 3 Jun 2002 13:11:55 -0000 1.13.2.3 --- project.pbxproj 3 Jun 2002 14:12:03 -0000 1.13.2.4 *************** *** 185,188 **** --- 185,189 ---- F5193F5202AB4D0601AADBC4, F58E24C102AB9840015D9B03, + F58E304002ABAA3C015D9B03, ); isa = PBXHeadersBuildPhase; *************** *** 204,207 **** --- 205,209 ---- F516627802AA4DC601A89878, F5193F5302AB4D0601AADBC4, + F58E304102ABAA3C015D9B03, ); isa = PBXSourcesBuildPhase; *************** *** 259,262 **** --- 261,266 ---- F5193F5002AB4D0601AADBC4, F5193F5102AB4D0601AADBC4, + F58E303E02ABAA3C015D9B03, + F58E303F02ABAA3C015D9B03, ); isa = PBXGroup; *************** *** 628,631 **** --- 632,636 ---- F5193F5402AB4D0601AADBC4, F58E24C202AB9840015D9B03, + F58E304202ABAA3C015D9B03, ); isa = PBXHeadersBuildPhase; *************** *** 728,731 **** --- 733,737 ---- F516627A02AA4DC601A89878, F5193F5502AB4D0601AADBC4, + F58E304302ABAA3D015D9B03, ); isa = PBXSourcesBuildPhase; *************** *** 2074,2077 **** --- 2080,2084 ---- F5193F5602AB4D0601AADBC4, F58E24C302AB9840015D9B03, + F58E304402ABAA3D015D9B03, ); isa = PBXHeadersBuildPhase; *************** *** 2093,2096 **** --- 2100,2104 ---- F516627C02AA4DC601A89878, F5193F5702AB4D0601AADBC4, + F58E304502ABAA3D015D9B03, ); isa = PBXSourcesBuildPhase; *************** *** 2198,2202 **** }; F5777C9001DE6747016C2008 = { ! buildActionMask = 8; files = ( ); --- 2206,2210 ---- }; F5777C9001DE6747016C2008 = { ! buildActionMask = 12; files = ( ); *************** *** 2208,2212 **** ); shellPath = /bin/sh; ! shellScript = "MKDIRS=\"mkdir -p\"\nAUTODOC=/usr/local/bin/autodoc\nAUTODOC_FLAGS=\"-copydocs -timestamp -allclasses\"\nAUTODOC_FORMAT=html\nAUTODOC_LANGUAGE=English\nexport AD_COPYRIGHT=\"MySQL Cocoa Project\"\n\n# If autodoc is not installed, we quit without any error\ntest -x $AUTODOC || exit 0\n\nPUBLIC_DOC_INSTALLDIR=\"$SYMROOT/$PRODUCT_NAME.framework/Resources/$AUTODOC_LANGUAGE.lproj/Documentation\"\n\n# We need to write down file names here\nAUTODOC_FILES=\"MCPConnection.h MCPResult.h MCPNull.h\"\nAUTODOC_DOCDIR=\"$PUBLIC_DOC_INSTALLDIR\"\n\nOTHER_AUTODOC_FLAGS=\"-typedirs -allclasses -combine -force -nosingles\"\n\nALL_AUTODOC_FLAGS=\"$AUTODOC_FLAGS $OTHER_AUTODOC_FLAGS\"\n\n$MKDIRS $PUBLIC_DOC_INSTALLDIR\n$AUTODOC $ALL_AUTODOC_FLAGS -format $AUTODOC_FORMAT -dest $AUTODOC_DOCDIR $AUTODOC_FILES\n"; }; F58E24C002AB9840015D9B03 = { --- 2216,2220 ---- ); shellPath = /bin/sh; ! shellScript = "MKDIRS=\"mkdir -p\"\nAUTODOC=/usr/local/bin/autodoc\nAUTODOC_FLAGS=\"-copydocs -timestamp -allclasses\"\nAUTODOC_FORMAT=html\nAUTODOC_LANGUAGE=English\nexport AD_COPYRIGHT=\"MySQL Cocoa Project\"\n\n# If autodoc is not installed, we quit without any error\ntest -x $AUTODOC || exit 0\n\nPUBLIC_DOC_INSTALLDIR=\"$SYMROOT/$PRODUCT_NAME.framework/Resources/$AUTODOC_LANGUAGE.lproj/Documentation\"\n\n# We need to write down file names here\nAUTODOC_FILES=\"MCPResultPlus.h MCPFastQueries.h MCPConnection.h MCPResult.h MCPNull.h\"\nAUTODOC_DOCDIR=\"$PUBLIC_DOC_INSTALLDIR\"\n\nOTHER_AUTODOC_FLAGS=\"-typedirs -allclasses -combine -force -nosingles\"\n\nALL_AUTODOC_FLAGS=\"$AUTODOC_FLAGS $OTHER_AUTODOC_FLAGS\"\n\n$MKDIRS $PUBLIC_DOC_INSTALLDIR\n$AUTODOC $ALL_AUTODOC_FLAGS -format $AUTODOC_FORMAT -dest $AUTODOC_DOCDIR $AUTODOC_FILES\n"; }; F58E24C002AB9840015D9B03 = { *************** *** 2242,2245 **** --- 2250,2299 ---- }; }; + F58E303E02ABAA3C015D9B03 = { + isa = PBXFileReference; + path = MCPFastQueries.h; + refType = 4; + }; + F58E303F02ABAA3C015D9B03 = { + isa = PBXFileReference; + path = MCPFastQueries.m; + refType = 4; + }; + F58E304002ABAA3C015D9B03 = { + fileRef = F58E303E02ABAA3C015D9B03; + isa = PBXBuildFile; + settings = { + }; + }; + F58E304102ABAA3C015D9B03 = { + fileRef = F58E303F02ABAA3C015D9B03; + isa = PBXBuildFile; + settings = { + }; + }; + F58E304202ABAA3C015D9B03 = { + fileRef = F58E303E02ABAA3C015D9B03; + isa = PBXBuildFile; + settings = { + }; + }; + F58E304302ABAA3D015D9B03 = { + fileRef = F58E303F02ABAA3C015D9B03; + isa = PBXBuildFile; + settings = { + }; + }; + F58E304402ABAA3D015D9B03 = { + fileRef = F58E303E02ABAA3C015D9B03; + isa = PBXBuildFile; + settings = { + }; + }; + F58E304502ABAA3D015D9B03 = { + fileRef = F58E303F02ABAA3C015D9B03; + isa = PBXBuildFile; + settings = { + }; + }; F59C3CF302AA3EFF017B4675 = { children = ( *************** *** 2374,2378 **** ); shellPath = /bin/sh; ! shellScript = "MKDIRS=\"mkdir -p\"\nAUTODOC=/usr/local/bin/autodoc\nAUTODOC_FLAGS=\"-copydocs -timestamp -allclasses\"\nAUTODOC_FORMAT=html\nAUTODOC_LANGUAGE=English\nexport AD_COPYRIGHT=\"MySQL Cocoa Project\"\n\n# If autodoc is not installed, we quit without any error\ntest -x $AUTODOC || exit 0\n\nPUBLIC_DOC_INSTALLDIR=\"$SYMROOT/$PRODUCT_NAME.framework/Resources/$AUTODOC_LANGUAGE.lproj/Documentation\"\n\n# We need to write down file names here\nAUTODOC_FILES=\"MCPConnection.h MCPResult.h MCPNull.h\"\nAUTODOC_DOCDIR=\"$PUBLIC_DOC_INSTALLDIR\"\n\nOTHER_AUTODOC_FLAGS=\"-typedirs -allclasses -combine -force -nosingles\"\n\nALL_AUTODOC_FLAGS=\"$AUTODOC_FLAGS $OTHER_AUTODOC_FLAGS\"\n\n$MKDIRS $PUBLIC_DOC_INSTALLDIR\n$AUTODOC $ALL_AUTODOC_FLAGS -format $AUTODOC_FORMAT -dest $AUTODOC_DOCDIR $AUTODOC_FILES\n"; }; F5F6CECD02A6946E015D9B03 = { --- 2428,2432 ---- ); shellPath = /bin/sh; ! shellScript = "MKDIRS=\"mkdir -p\"\nAUTODOC=/usr/local/bin/autodoc\nAUTODOC_FLAGS=\"-copydocs -timestamp -allclasses\"\nAUTODOC_FORMAT=html\nAUTODOC_LANGUAGE=English\nexport AD_COPYRIGHT=\"MySQL Cocoa Project\"\n\n# If autodoc is not installed, we quit without any error\ntest -x $AUTODOC || exit 0\n\nPUBLIC_DOC_INSTALLDIR=\"$SYMROOT/$PRODUCT_NAME.framework/Resources/$AUTODOC_LANGUAGE.lproj/Documentation\"\n\n# We need to write down file names here\nAUTODOC_FILES=\"MCPConnection.h MCPResult.h MCPNull.h MCPResultPlus.h MCPFastQueries.h\"\nAUTODOC_DOCDIR=\"$PUBLIC_DOC_INSTALLDIR\"\n\nOTHER_AUTODOC_FLAGS=\"-typedirs -allclasses -combine -force -nosingles\"\n\nALL_AUTODOC_FLAGS=\"$AUTODOC_FLAGS $OTHER_AUTODOC_FLAGS\"\n\n$MKDIRS $PUBLIC_DOC_INSTALLDIR\n$AUTODOC $ALL_AUTODOC_FLAGS -format $AUTODOC_FORMAT -dest $AUTODOC_DOCDIR $AUTODOC_FILES\n"; }; F5F6CECD02A6946E015D9B03 = { Index: cohen.pbxuser =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj/cohen.pbxuser,v retrieving revision 1.13.2.3 retrieving revision 1.13.2.4 diff -C2 -d -r1.13.2.3 -r1.13.2.4 *** cohen.pbxuser 3 Jun 2002 13:11:55 -0000 1.13.2.3 --- cohen.pbxuser 3 Jun 2002 14:12:03 -0000 1.13.2.4 *************** *** 3,7 **** 0867D690FE84028FC02AAC07 = { activeBuildStyle = 014CEA440018CDF011CA2923; ! activeTarget = F59C3D3D02AA458C017B4675; addToTargets = ( 0867D69CFE84028FC02AAC07, --- 3,7 ---- 0867D690FE84028FC02AAC07 = { activeBuildStyle = 014CEA440018CDF011CA2923; ! activeTarget = 0867D69CFE84028FC02AAC07; addToTargets = ( 0867D69CFE84028FC02AAC07, |
From: Serge C. <ser...@us...> - 2002-06-03 14:11:54
|
Update of /cvsroot/mysql-cocoa/SMySQL In directory usw-pr-cvs1:/tmp/cvs-serv510 Modified Files: Tag: version-2 TO_DO Added Files: Tag: version-2 MCPFastQueries.h MCPFastQueries.m Log Message: Added the category MCPFastQueries to MCPConnection. Serge Cohen; MySQL Cocoa project, 2002-06-03. --- NEW FILE: MCPFastQueries.h --- // // MCPFastQueries.h // SMySQL // // Created by Serge Cohen (ser...@m4...) on Mon Jun 03 2002. // Copyright (c) 2001 MySQL Cocoa project. // // This code is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 of the License, or any later version. // // This code is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // For a copy of the GNU General Public License, visit <http://www.gnu.org/> or // write to the Free Software Foundation, Inc., 59 Temple Place--Suite 330, // Boston, MA 02111-1307, USA. // // More info at <http://mysql-cocoa.sourceforge.net/> // // $Id: MCPFastQueries.h,v 1.1.2.1 2002/06/03 14:11:51 sergecohen Exp $ // $Author: sergecohen $ #import <Foundation/Foundation.h> #import "MCPConnection.h" @interface MCPConnection (MCPFastQueries) /*" Returns directly a proper NS object, or a collection (NSArray, NSDictionary...). "*/ - (id) getFirstFieldFromQuery:(NSString *) aQuery; - (id) getFirstRowFromQuery:(NSString *) aQuery asType:(MCPReturnType) aType; - (id) getAllRowsFromQuery:(NSString *) aQuery asType:(MCPReturnType) aType; - (NSArray *) getQuery:(NSString *) aQuery colWithIndex:(unsigned int) aCol; - (NSArray *) getQuery:(NSString *) aQuery colWithName:(NSString *) aColName; @end --- NEW FILE: MCPFastQueries.m --- // // MCPFastQueries.m // SMySQL // // Created by Serge Cohen (ser...@m4...) on Mon Jun 03 2002. // Copyright (c) 2001 MySQL Cocoa project. // // This code is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 of the License, or any later version. // // This code is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // For a copy of the GNU General Public License, visit <http://www.gnu.org/> or // write to the Free Software Foundation, Inc., 59 Temple Place--Suite 330, // Boston, MA 02111-1307, USA. // // More info at <http://mysql-cocoa.sourceforge.net/> // // $Id: MCPFastQueries.m,v 1.1.2.1 2002/06/03 14:11:51 sergecohen Exp $ // $Author: sergecohen $ #import "MCPResultPlus.h" #import "MCPFastQueries.h" @implementation MCPConnection (MCPFastQueries) /*" This actegory is made up to keep the extra methods out or the core of the framework. Basicly this is the place to add methods which are useful, but are just wrappers to the methods of the core (MCPConnection, MCPResult). The purpous being to have a single line call available for current tasks which otherwise would need a couple of lines and object defined. "*/ - (id) getFirstFieldFromQuery:(NSString *) aQuery /*" Get the first field of the first row of the result from the query (aQuery). "*/ { MCPResult *theResult = [self queryString:aQuery]; return [[theResult fetchRowAsType:MCPTypeArray] objectAtIndex:0]; } - (id) getFirstRowFromQuery:(NSString *) aQuery asType:(MCPReturnType) aType /*" Get the firdst row of the result from the query aQuery, in a collection of type determined by aType (MCPTypeArray or MCPTypeDictionary) "*/ { MCPResult *theResult = [self queryString:aQuery]; return [theResult fetchRowAsType:aType]; } - (id) getAllRowsFromQuery:(NSString *) aQuery asType:(MCPReturnType) aType /*" Get a bidimensional table of the whole rows of the result from the query aQuery. The type of the result is choosen by aType, it can be (MCPTypeArray, MCPTypeDictionary, MCPTypeFlippedArray & MCPTypeFlippedDictionary). Description of the types can be found in method #{fetch2DResultAsType:}. "*/ { MCPResult *theResult = [self queryString:aQuery]; return [theResult fetch2DResultAsType:aType]; } - (NSArray *) getQuery:(NSString *) aQuery colWithIndex:(unsigned int) aCol /*" Get a column (as an NSArray) of the result from the query aQuery. The column is choosen from it's index, starting from 0. "*/ { MCPResult *theResult = [self queryString:aQuery]; return [theResult fetchColAtIndex:aCol]; } - (NSArray *) getQuery:(NSString *) aQuery colWithName:(NSString *) aColName /*" Get a column (as an NSArray) of the result from the query aQuery. The column is choosen from it's name. "*/ { MCPResult *theResult = [self queryString:aQuery]; return [theResult fetchColWithName:aColName]; } @end Index: TO_DO =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/TO_DO,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** TO_DO 3 Jun 2002 13:11:45 -0000 1.1.2.2 --- TO_DO 3 Jun 2002 14:11:51 -0000 1.1.2.3 *************** *** 3,8 **** ++Handling NULL fields: - Create a MCPNull object to reflect NULL columns values in retrieved table rows. ! - Create a "MCPNull" category for NSObject with only one method : isMCPNull (Being able to check if any object returned by SMySQL is a MCPNull) -> Ok. --- 3,9 ---- ++Handling NULL fields: - Create a MCPNull object to reflect NULL columns values in retrieved table rows. ! - Create a "MCPNull" category for NSObject with only one method : isNSNull (Being able to check if any object returned by SMySQL is a MCPNull) -> Ok. + ++++++ Indeed I used the NSNull class. |
From: Serge C. <ser...@us...> - 2002-06-03 13:39:30
|
Update of /cvsroot/mysql-cocoa/SMySQL In directory usw-pr-cvs1:/tmp/cvs-serv22417 Modified Files: Tag: version-2 SMySQL.h SMySQLConstants.h MCPConnection.h MCPConnection.m MCPResult.h MCPResult.m MCPNull.h MCPNull.m MCPResultPlus.h MCPResultPlus.m Log Message: Update comments of files, to have both Id and Author. Serge Cohen; MySQL Cocoa project, 2002-06-03. Index: SMySQL.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQL.h,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -C2 -d -r1.2.2.2 -r1.2.2.3 *** SMySQL.h 3 Jun 2002 13:11:45 -0000 1.2.2.2 --- SMySQL.h 3 Jun 2002 13:39:24 -0000 1.2.2.3 *************** *** 21,24 **** --- 21,27 ---- * More info at <http://mysql-cocoa.sourceforge.net/> * + * + * $Id$ + * $Author$ */ Index: SMySQLConstants.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/SMySQLConstants.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** SMySQLConstants.h 3 Jun 2002 13:11:45 -0000 1.1.2.1 --- SMySQLConstants.h 3 Jun 2002 13:39:24 -0000 1.1.2.2 *************** *** 21,25 **** // More info at <http://mysql-cocoa.sourceforge.net/> // ! // $Id: --- 21,26 ---- // More info at <http://mysql-cocoa.sourceforge.net/> // ! // $Id$ ! // $Author$ Index: MCPConnection.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPConnection.h,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** MCPConnection.h 3 Jun 2002 13:11:45 -0000 1.1.2.3 --- MCPConnection.h 3 Jun 2002 13:39:24 -0000 1.1.2.4 *************** *** 22,25 **** --- 22,26 ---- // // $Id$ + // $Author$ Index: MCPConnection.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPConnection.m,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** MCPConnection.m 3 Jun 2002 13:11:45 -0000 1.1.2.3 --- MCPConnection.m 3 Jun 2002 13:39:24 -0000 1.1.2.4 *************** *** 22,26 **** // // $Id$ ! #import "MCPConnection.h" --- 22,27 ---- // // $Id$ ! // $Author$ ! #import "MCPConnection.h" Index: MCPResult.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPResult.h,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** MCPResult.h 3 Jun 2002 13:11:46 -0000 1.1.2.3 --- MCPResult.h 3 Jun 2002 13:39:24 -0000 1.1.2.4 *************** *** 22,25 **** --- 22,26 ---- // // $Id$ + // $Author$ Index: MCPResult.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPResult.m,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** MCPResult.m 3 Jun 2002 13:11:46 -0000 1.1.2.3 --- MCPResult.m 3 Jun 2002 13:39:24 -0000 1.1.2.4 *************** *** 22,25 **** --- 22,26 ---- // // $Id$ + // $Author$ Index: MCPNull.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPNull.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** MCPNull.h 3 Jun 2002 13:11:46 -0000 1.1.2.1 --- MCPNull.h 3 Jun 2002 13:39:24 -0000 1.1.2.2 *************** *** 21,25 **** // More info at <http://mysql-cocoa.sourceforge.net/> // ! // $Id: #import <Foundation/Foundation.h> --- 21,26 ---- // More info at <http://mysql-cocoa.sourceforge.net/> // ! // $Id$ ! // $Author$ #import <Foundation/Foundation.h> Index: MCPNull.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPNull.m,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** MCPNull.m 3 Jun 2002 13:11:46 -0000 1.1.2.1 --- MCPNull.m 3 Jun 2002 13:39:24 -0000 1.1.2.2 *************** *** 21,25 **** // More info at <http://mysql-cocoa.sourceforge.net/> // ! // $Id: #import "MCPNull.h" --- 21,26 ---- // More info at <http://mysql-cocoa.sourceforge.net/> // ! // $Id$ ! // $Author$ #import "MCPNull.h" Index: MCPResultPlus.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPResultPlus.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** MCPResultPlus.h 3 Jun 2002 13:11:46 -0000 1.1.2.1 --- MCPResultPlus.h 3 Jun 2002 13:39:24 -0000 1.1.2.2 *************** *** 21,25 **** // More info at <http://mysql-cocoa.sourceforge.net/> // ! // $Id: #import <Foundation/Foundation.h> --- 21,26 ---- // More info at <http://mysql-cocoa.sourceforge.net/> // ! // $Id$ ! // $Author$ #import <Foundation/Foundation.h> Index: MCPResultPlus.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPResultPlus.m,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** MCPResultPlus.m 3 Jun 2002 13:11:46 -0000 1.1.2.1 --- MCPResultPlus.m 3 Jun 2002 13:39:24 -0000 1.1.2.2 *************** *** 21,25 **** // More info at <http://mysql-cocoa.sourceforge.net/> // ! // $Id: #import "MCPResultPlus.h" --- 21,26 ---- // More info at <http://mysql-cocoa.sourceforge.net/> // ! // $Id$ ! // $Author$ #import "MCPResultPlus.h" |
From: Serge C. <ser...@us...> - 2002-06-03 13:11:58
|
Update of /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj In directory usw-pr-cvs1:/tmp/cvs-serv12586 Modified Files: Tag: version-2 project.pbxproj cohen.pbxuser Log Message: -Added support for NULL fields in the results. -Easier to maintain methods for retrieving row and types information -Added a MCPResultPlus category, for extra methods to handle and get result rows and column (per column, and 2D) Serge Cohen; MySQL Cocoa project, 2002-06-03.... Index: project.pbxproj =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj/project.pbxproj,v retrieving revision 1.13.2.2 retrieving revision 1.13.2.3 diff -C2 -d -r1.13.2.2 -r1.13.2.3 *** project.pbxproj 2 Jun 2002 12:46:16 -0000 1.13.2.2 --- project.pbxproj 3 Jun 2002 13:11:55 -0000 1.13.2.3 *************** *** 182,185 **** --- 182,188 ---- F51B528301CA90DE0130DCEA, F51B528401CA90DE0130DCEA, + F516627702AA4DC601A89878, + F5193F5202AB4D0601AADBC4, + F58E24C102AB9840015D9B03, ); isa = PBXHeadersBuildPhase; *************** *** 199,202 **** --- 202,207 ---- F5165EBD01C50A5A0116CAC1, F5165EBE01C50A5A0116CAC1, + F516627802AA4DC601A89878, + F5193F5302AB4D0601AADBC4, ); isa = PBXSourcesBuildPhase; *************** *** 245,252 **** --- 250,262 ---- children = ( F5165EBF01C50A6F0116CAC1, + F58E24C002AB9840015D9B03, F5165EB701C50A5A0116CAC1, F5165EB801C50A5A0116CAC1, F5165EB901C50A5A0116CAC1, F5165EBA01C50A5A0116CAC1, + F516627502AA4DC601A89878, + F516627602AA4DC601A89878, + F5193F5002AB4D0601AADBC4, + F5193F5102AB4D0601AADBC4, ); isa = PBXGroup; *************** *** 406,409 **** --- 416,529 ---- target = 0867D69CFE84028FC02AAC07; }; + F516627502AA4DC601A89878 = { + isa = PBXFileReference; + path = MCPNull.h; + refType = 4; + }; + F516627602AA4DC601A89878 = { + isa = PBXFileReference; + path = MCPNull.m; + refType = 4; + }; + F516627702AA4DC601A89878 = { + fileRef = F516627502AA4DC601A89878; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + F516627802AA4DC601A89878 = { + fileRef = F516627602AA4DC601A89878; + isa = PBXBuildFile; + settings = { + }; + }; + F516627902AA4DC601A89878 = { + fileRef = F516627502AA4DC601A89878; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + F516627A02AA4DC601A89878 = { + fileRef = F516627602AA4DC601A89878; + isa = PBXBuildFile; + settings = { + }; + }; + F516627B02AA4DC601A89878 = { + fileRef = F516627502AA4DC601A89878; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + F516627C02AA4DC601A89878 = { + fileRef = F516627602AA4DC601A89878; + isa = PBXBuildFile; + settings = { + }; + }; + F5193F5002AB4D0601AADBC4 = { + isa = PBXFileReference; + path = MCPResultPlus.h; + refType = 4; + }; + F5193F5102AB4D0601AADBC4 = { + isa = PBXFileReference; + path = MCPResultPlus.m; + refType = 4; + }; + F5193F5202AB4D0601AADBC4 = { + fileRef = F5193F5002AB4D0601AADBC4; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + F5193F5302AB4D0601AADBC4 = { + fileRef = F5193F5102AB4D0601AADBC4; + isa = PBXBuildFile; + settings = { + }; + }; + F5193F5402AB4D0601AADBC4 = { + fileRef = F5193F5002AB4D0601AADBC4; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + F5193F5502AB4D0601AADBC4 = { + fileRef = F5193F5102AB4D0601AADBC4; + isa = PBXBuildFile; + settings = { + }; + }; + F5193F5602AB4D0601AADBC4 = { + fileRef = F5193F5002AB4D0601AADBC4; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + F5193F5702AB4D0601AADBC4 = { + fileRef = F5193F5102AB4D0601AADBC4; + isa = PBXBuildFile; + settings = { + }; + }; F51A62D4022D7B3301952E7A = { buildRules = ( *************** *** 505,508 **** --- 625,631 ---- F51A62DF022D7C6201952E7A, F51A62DD022D7C6201952E7A, + F516627902AA4DC601A89878, + F5193F5402AB4D0601AADBC4, + F58E24C202AB9840015D9B03, ); isa = PBXHeadersBuildPhase; *************** *** 603,606 **** --- 726,731 ---- F5649F0B023FD60301D04C4B, F5649F0C023FD60301D04C4B, + F516627A02AA4DC601A89878, + F5193F5502AB4D0601AADBC4, ); isa = PBXSourcesBuildPhase; *************** *** 1946,1949 **** --- 2071,2077 ---- F5649F18023FE1A901D04C4B, F5649F19023FE1A901D04C4B, + F516627B02AA4DC601A89878, + F5193F5602AB4D0601AADBC4, + F58E24C302AB9840015D9B03, ); isa = PBXHeadersBuildPhase; *************** *** 1963,1966 **** --- 2091,2096 ---- F5649F1B023FE1A901D04C4B, F5649F1C023FE1A901D04C4B, + F516627C02AA4DC601A89878, + F5193F5702AB4D0601AADBC4, ); isa = PBXSourcesBuildPhase; *************** *** 2068,2072 **** }; F5777C9001DE6747016C2008 = { ! buildActionMask = 12; files = ( ); --- 2198,2202 ---- }; F5777C9001DE6747016C2008 = { ! buildActionMask = 8; files = ( ); *************** *** 2078,2082 **** ); shellPath = /bin/sh; ! shellScript = "MKDIRS=\"mkdir -p\"\nAUTODOC=/usr/local/bin/autodoc\nAUTODOC_FLAGS=\"-copydocs -timestamp -allclasses\"\nAUTODOC_FORMAT=html\nAUTODOC_LANGUAGE=English\nexport AD_COPYRIGHT=\"MySQL Cocoa Project\"\n\n# If autodoc is not installed, we quit without any error\ntest -x $AUTODOC || exit 0\n\nPUBLIC_DOC_INSTALLDIR=\"$SYMROOT/$PRODUCT_NAME.framework/Resources/$AUTODOC_LANGUAGE.lproj/Documentation\"\n\n# We need to write down file names here\nAUTODOC_FILES=\"MCPConnection.h MCPResult.h\"\nAUTODOC_DOCDIR=\"$PUBLIC_DOC_INSTALLDIR\"\n\nOTHER_AUTODOC_FLAGS=\"-typedirs -allclasses -combine -force -nosingles\"\n\nALL_AUTODOC_FLAGS=\"$AUTODOC_FLAGS $OTHER_AUTODOC_FLAGS\"\n\n$MKDIRS $PUBLIC_DOC_INSTALLDIR\n$AUTODOC $ALL_AUTODOC_FLAGS -format $AUTODOC_FORMAT -dest $AUTODOC_DOCDIR $AUTODOC_FILES\n"; }; F59C3CF302AA3EFF017B4675 = { --- 2208,2244 ---- ); shellPath = /bin/sh; ! shellScript = "MKDIRS=\"mkdir -p\"\nAUTODOC=/usr/local/bin/autodoc\nAUTODOC_FLAGS=\"-copydocs -timestamp -allclasses\"\nAUTODOC_FORMAT=html\nAUTODOC_LANGUAGE=English\nexport AD_COPYRIGHT=\"MySQL Cocoa Project\"\n\n# If autodoc is not installed, we quit without any error\ntest -x $AUTODOC || exit 0\n\nPUBLIC_DOC_INSTALLDIR=\"$SYMROOT/$PRODUCT_NAME.framework/Resources/$AUTODOC_LANGUAGE.lproj/Documentation\"\n\n# We need to write down file names here\nAUTODOC_FILES=\"MCPConnection.h MCPResult.h MCPNull.h\"\nAUTODOC_DOCDIR=\"$PUBLIC_DOC_INSTALLDIR\"\n\nOTHER_AUTODOC_FLAGS=\"-typedirs -allclasses -combine -force -nosingles\"\n\nALL_AUTODOC_FLAGS=\"$AUTODOC_FLAGS $OTHER_AUTODOC_FLAGS\"\n\n$MKDIRS $PUBLIC_DOC_INSTALLDIR\n$AUTODOC $ALL_AUTODOC_FLAGS -format $AUTODOC_FORMAT -dest $AUTODOC_DOCDIR $AUTODOC_FILES\n"; ! }; ! F58E24C002AB9840015D9B03 = { ! isa = PBXFileReference; ! path = SMySQLConstants.h; ! refType = 4; ! }; ! F58E24C102AB9840015D9B03 = { ! fileRef = F58E24C002AB9840015D9B03; ! isa = PBXBuildFile; ! settings = { ! ATTRIBUTES = ( ! Public, ! ); ! }; ! }; ! F58E24C202AB9840015D9B03 = { ! fileRef = F58E24C002AB9840015D9B03; ! isa = PBXBuildFile; ! settings = { ! ATTRIBUTES = ( ! Public, ! ); ! }; ! }; ! F58E24C302AB9840015D9B03 = { ! fileRef = F58E24C002AB9840015D9B03; ! isa = PBXBuildFile; ! settings = { ! ATTRIBUTES = ( ! Public, ! ); ! }; }; F59C3CF302AA3EFF017B4675 = { *************** *** 2212,2216 **** ); shellPath = /bin/sh; ! shellScript = "MKDIRS=\"mkdir -p\"\nAUTODOC=/usr/local/bin/autodoc\nAUTODOC_FLAGS=\"-copydocs -timestamp -allclasses\"\nAUTODOC_FORMAT=html\nAUTODOC_LANGUAGE=English\nexport AD_COPYRIGHT=\"MySQL Cocoa Project\"\n\n# If autodoc is not installed, we quit without any error\ntest -x $AUTODOC || exit 0\n\nPUBLIC_DOC_INSTALLDIR=\"$SYMROOT/$PRODUCT_NAME.framework/Resources/$AUTODOC_LANGUAGE.lproj/Documentation\"\n\n# We need to write down file names here\nAUTODOC_FILES=\"MCPConnection.h MCPResult.h\"\nAUTODOC_DOCDIR=\"$PUBLIC_DOC_INSTALLDIR\"\n\nOTHER_AUTODOC_FLAGS=\"-typedirs -allclasses -combine -force -nosingles\"\n\nALL_AUTODOC_FLAGS=\"$AUTODOC_FLAGS $OTHER_AUTODOC_FLAGS\"\n\n$MKDIRS $PUBLIC_DOC_INSTALLDIR\n$AUTODOC $ALL_AUTODOC_FLAGS -format $AUTODOC_FORMAT -dest $AUTODOC_DOCDIR $AUTODOC_FILES\n"; }; F5F6CECD02A6946E015D9B03 = { --- 2374,2378 ---- ); shellPath = /bin/sh; ! shellScript = "MKDIRS=\"mkdir -p\"\nAUTODOC=/usr/local/bin/autodoc\nAUTODOC_FLAGS=\"-copydocs -timestamp -allclasses\"\nAUTODOC_FORMAT=html\nAUTODOC_LANGUAGE=English\nexport AD_COPYRIGHT=\"MySQL Cocoa Project\"\n\n# If autodoc is not installed, we quit without any error\ntest -x $AUTODOC || exit 0\n\nPUBLIC_DOC_INSTALLDIR=\"$SYMROOT/$PRODUCT_NAME.framework/Resources/$AUTODOC_LANGUAGE.lproj/Documentation\"\n\n# We need to write down file names here\nAUTODOC_FILES=\"MCPConnection.h MCPResult.h MCPNull.h\"\nAUTODOC_DOCDIR=\"$PUBLIC_DOC_INSTALLDIR\"\n\nOTHER_AUTODOC_FLAGS=\"-typedirs -allclasses -combine -force -nosingles\"\n\nALL_AUTODOC_FLAGS=\"$AUTODOC_FLAGS $OTHER_AUTODOC_FLAGS\"\n\n$MKDIRS $PUBLIC_DOC_INSTALLDIR\n$AUTODOC $ALL_AUTODOC_FLAGS -format $AUTODOC_FORMAT -dest $AUTODOC_DOCDIR $AUTODOC_FILES\n"; }; F5F6CECD02A6946E015D9B03 = { Index: cohen.pbxuser =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj/cohen.pbxuser,v retrieving revision 1.13.2.2 retrieving revision 1.13.2.3 diff -C2 -d -r1.13.2.2 -r1.13.2.3 *** cohen.pbxuser 2 Jun 2002 12:46:16 -0000 1.13.2.2 --- cohen.pbxuser 3 Jun 2002 13:11:55 -0000 1.13.2.3 *************** *** 2,8 **** { 0867D690FE84028FC02AAC07 = { ! activeBuildStyle = F51A62D4022D7B3301952E7A; activeTarget = F59C3D3D02AA458C017B4675; addToTargets = ( ); breakpoints = ( --- 2,11 ---- { 0867D690FE84028FC02AAC07 = { ! activeBuildStyle = 014CEA440018CDF011CA2923; activeTarget = F59C3D3D02AA458C017B4675; addToTargets = ( + 0867D69CFE84028FC02AAC07, + F51A62D7022D7C2A01952E7A, + F5649F0E023FDCA201D04C4B, ); breakpoints = ( *************** *** 10,33 **** perUserDictionary = { PBXWorkspaceConfiguration = { ! ContentSize = "{967, 573}"; LeftSlideOut = { ActiveTab = 0; ! Frame = "{{0, 23}, {967, 550}}"; Split0 = { ! Frame = "{{232, 0}, {735, 550}}"; Split0 = { ! Frame = "{{0, 24}, {735, 526}}"; }; SplitCount = 1; Tab0 = { Debugger = { ! Frame = "{{0, 0}, {484, 208}}"; Split0 = { ! Frame = "{{0, 25}, {484, 183}}"; Split0 = { ! Frame = "{{0, 0}, {236, 183}}"; }; Split1 = { ! Frame = "{{245, 0}, {239, 183}}"; }; SplitCount = 2; --- 13,38 ---- perUserDictionary = { PBXWorkspaceConfiguration = { ! ContentSize = "{1024, 674}"; LeftSlideOut = { ActiveTab = 0; ! Frame = "{{0, 23}, {1024, 651}}"; Split0 = { ! ActiveTab = 2; ! Frame = "{{232, 0}, {792, 651}}"; Split0 = { ! Frame = "{{0, 216}, {792, 435}}"; }; SplitCount = 1; Tab0 = { Debugger = { ! ActiveTab = 1; ! Frame = "{{0, 0}, {750, 305}}"; Split0 = { ! Frame = "{{0, 167}, {750, 138}}"; Split0 = { ! Frame = "{{0, 0}, {365, 138}}"; }; Split1 = { ! Frame = "{{374, 0}, {376, 138}}"; }; SplitCount = 2; *************** *** 38,62 **** }; Tab1 = { ! Frame = "{{0, 0}, {100, 50}}"; }; TabCount = 2; }; ! Frame = "{{0, 0}, {484, 208}}"; LauncherConfigVersion = 4; }; Tab1 = { ! Frame = "{{0, 0}, {735, 208}}"; LauncherConfigVersion = 3; Runner = { ! Frame = "{{0, 0}, {735, 208}}"; }; }; Tab2 = { ! BuildMessageFrame = "{{0, 0}, {745, 95}}"; ! BuildTranscriptFrame = "{{0, 104}, {745, 90}}"; ! Frame = "{{0, 0}, {743, 192}}"; }; Tab3 = { ! Frame = "{{0, 0}, {735, 295}}"; }; TabCount = 4; --- 43,67 ---- }; Tab1 = { ! Frame = "{{0, 0}, {750, 143}}"; }; TabCount = 2; }; ! Frame = "{{0, 0}, {750, 305}}"; LauncherConfigVersion = 4; }; Tab1 = { ! Frame = "{{0, 0}, {792, 208}}"; LauncherConfigVersion = 3; Runner = { ! Frame = "{{0, 0}, {792, 208}}"; }; }; Tab2 = { ! BuildMessageFrame = "{{0, 0}, {794, 95}}"; ! BuildTranscriptFrame = "{{0, 104}, {794, 90}}"; ! Frame = "{{0, 0}, {792, 192}}"; }; Tab3 = { ! Frame = "{{0, 0}, {792, 295}}"; }; TabCount = 4; *************** *** 64,68 **** SplitCount = 1; Tab0 = { ! Frame = "{{0, 0}, {208, 550}}"; }; Tab1 = { --- 69,73 ---- SplitCount = 1; Tab0 = { ! Frame = "{{0, 0}, {208, 651}}"; }; Tab1 = { *************** *** 86,94 **** }; Tab4 = { ! Frame = "{{0, 0}, {250, 100}}"; }; TabCount = 5; }; ! WindowLocation = "{29, 73}"; }; }; --- 91,99 ---- }; Tab4 = { ! Frame = "{{0, 0}, {250, 651}}"; }; TabCount = 5; }; ! WindowLocation = "{0, 10}"; }; }; *************** *** 114,117 **** --- 119,127 ---- }; }; + F5165EB901C50A5A0116CAC1 = { + uiCtxt = { + sepNavWindowFrame = "{{15, 456}, {775, 285}}"; + }; + }; F5165EBF01C50A6F0116CAC1 = { uiCtxt = { *************** *** 119,122 **** --- 129,137 ---- }; }; + F516627502AA4DC601A89878 = { + uiCtxt = { + sepNavWindowFrame = "{{38, 218}, {750, 502}}"; + }; + }; F51A62D7022D7C2A01952E7A = { activeExec = 0; *************** *** 159,163 **** ); debuggerPlugin = GDBDebugging; ! dylibVariantSuffix = ""; enableDebugStr = 1; environmentEntries = ( --- 174,178 ---- ); debuggerPlugin = GDBDebugging; ! dylibVariantSuffix = _debug; enableDebugStr = 1; environmentEntries = ( |
From: Serge C. <ser...@us...> - 2002-06-03 13:11:54
|
Update of /cvsroot/mysql-cocoa/SMySQL In directory usw-pr-cvs1:/tmp/cvs-serv12487 Modified Files: Tag: version-2 TO_DO SMySQL.h MCPConnection.h MCPConnection.m MCPResult.h MCPResult.m Added Files: Tag: version-2 SMySQLConstants.h MCPNull.h MCPNull.m MCPResultPlus.h MCPResultPlus.m Log Message: -Added support for NULL fields in the results. -Easier to maintain methods for retrieving row and types information -Added a MCPResultPlus category, for extra methods to handle and get result rows and column (per column, and 2D) Serge Cohen; MySQL Cocoa project, 2002-06-03. --- NEW FILE: SMySQLConstants.h --- // // SMySQLConstants.h // SMySQL // // Created by Serge Cohen (ser...@m4...) on Mon Jun 03 2002. // Copyright (c) 2001 MySQL Cocoa project. // // This code is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 of the License, or any later version. // // This code is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // For a copy of the GNU General Public License, visit <http://www.gnu.org/> or // write to the Free Software Foundation, Inc., 59 Temple Place--Suite 330, // Boston, MA 02111-1307, USA. // // More info at <http://mysql-cocoa.sourceforge.net/> // // $Id: typedef enum { MCPTypeArray = 1, MCPTypeDictionary = 2, MCPTypeFlippedArray = 3, MCPTypeFlippedDictionary = 4 } MCPReturnType; --- NEW FILE: MCPNull.h --- // // MCPNull.h // SMySQL // // Created by Serge Cohen (ser...@m4...) on Sun Jun 02 2002. // Copyright (c) 2001 MySQL Cocoa project. // // This code is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 of the License, or any later version. // // This code is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // For a copy of the GNU General Public License, visit <http://www.gnu.org/> or // write to the Free Software Foundation, Inc., 59 Temple Place--Suite 330, // Boston, MA 02111-1307, USA. // // More info at <http://mysql-cocoa.sourceforge.net/> // // $Id: #import <Foundation/Foundation.h> @interface NSObject (MCPNSNullTest) /*" Addin to NSObject. "*/ - (BOOL) isNSNull; @end --- NEW FILE: MCPNull.m --- // // MCPNull.m // SMySQL // // Created by Serge Cohen (ser...@m4...) on Sun Jun 02 2002. // Copyright (c) 2001 MySQL Cocoa project. // // This code is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 of the License, or any later version. // // This code is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // For a copy of the GNU General Public License, visit <http://www.gnu.org/> or // write to the Free Software Foundation, Inc., 59 Temple Place--Suite 330, // Boston, MA 02111-1307, USA. // // More info at <http://mysql-cocoa.sourceforge.net/> // // $Id: #import "MCPNull.h" @implementation NSObject (MCPNSNullTest) /*" This Category is meant to make any kind of object the possible target to the test (isNSNull) "*/ - (BOOL) isNSNull { return [self isMemberOfClass:[NSNull class]]; } @end --- NEW FILE: MCPResultPlus.h --- // // MCPResultPlus.h // SMySQL // // Created by Serge Cohen (ser...@m4...) on Mon Jun 03 2002. // Copyright (c) 2001 MySQL Cocoa project. // // This code is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 of the License, or any later version. // // This code is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // For a copy of the GNU General Public License, visit <http://www.gnu.org/> or // write to the Free Software Foundation, Inc., 59 Temple Place--Suite 330, // Boston, MA 02111-1307, USA. // // More info at <http://mysql-cocoa.sourceforge.net/> // // $Id: #import <Foundation/Foundation.h> #import "MCPResult.h" @interface MCPResult (MCPResultPlus) /*" Getting a complete column as an array "*/ - (NSArray *) fetchColAtIndex:(unsigned int) aCol; - (NSArray *) fetchColWithName:(NSString *) aColName; /*" Getting the complete result as 2D array "*/ - (id) fetch2DResultAsType:(MCPReturnType) aType; @end --- NEW FILE: MCPResultPlus.m --- // // MCPResultPlus.m // SMySQL // // Created by Serge Cohen (ser...@m4...) on Mon Jun 03 2002. // Copyright (c) 2001 MySQL Cocoa project. // // This code is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 of the License, or any later version. // // This code is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // For a copy of the GNU General Public License, visit <http://www.gnu.org/> or // write to the Free Software Foundation, Inc., 59 Temple Place--Suite 330, // Boston, MA 02111-1307, USA. // // More info at <http://mysql-cocoa.sourceforge.net/> // // $Id: #import "MCPResultPlus.h" @implementation MCPResult (MCPResultPlus) - (NSArray *) fetchColAtIndex:(unsigned int) aCol /*" Getting a complete column into a NSArray (1D). The index starts from 0 (first column). The index 0 of the returned array always correspond to the first row (ie: returned NSArray is indexed by row number), the read position is restored after to it's initial position after the read. "*/ { NSMutableArray *theCol = [NSMutableArray arrayWithCapacity:[self numOfRows]]; MYSQL_ROW_OFFSET thePosition; NSArray *theRow; if ((mResult == NULL) || ([self numOfRows] == 0)) { // If there is no results, returns nil. return nil; } if (aCol >= mNumOfFields) { // Bad column number NSLog (@"The index : %d is not within the range 0 - %d\n", (long)aCol, (long)mNumOfFields); return nil; } thePosition = mysql_row_tell(mResult); [self dataSeek:0]; // One might want to have optimized code here. Maybe in later versions while (theRow = [self fetchRowAsType:MCPTypeArray]) { [theCol addObject:[theRow objectAtIndex:aCol]]; } // Returning to the proper row mysql_row_seek(mResult,thePosition); return [NSArray arrayWithArray:theCol]; } - (NSArray *) fetchColWithName:(NSString *) aColName /*" The same as #{fetchColAtIndex:}, but the choice of the column is done by it's field name. Indeed it is just a wrapper to #{fetchColAtIndex}. "*/ { unsigned int theCol; if (mResult == NULL) { // If there is no results, returns nil. return nil; } if (mNames == nil) { [self fetchFieldsName]; } theCol = [mNames indexOfObject:aColName]; if (theCol == NSNotFound) { NSLog(@"No column have been found with name : %@\n",aColName); return nil; } return [self fetchColAtIndex:theCol]; } - (id) fetch2DResultAsType:(MCPReturnType) aType; /*" Returns the complete result table in a 2D object, which type depends on aType: - MCPTypeArray : a NSArray of rows as NSArray, - MCPTypeDictionary : a NSArray of rows as NSDictionary, - MCPTypeFlippedArray : a NSArray of columns (as NSArray), - MCPTypeFlippedDictionary : a NSDictionary of columns (as NSArray) In any case the read position is restored at the end of the call (hence a fetchRow will get the same row wether this method is called before it or not). "*/ { id theTable, theVect; MYSQL_ROW_OFFSET thePosition; unsigned int i; if (mResult == NULL) { // If there is no results, returns nil. return nil; } thePosition = mysql_row_tell(mResult); [self dataSeek:0]; switch (aType) { case MCPTypeArray : theTable = [NSMutableArray arrayWithCapacity:[self numOfRows]]; while (theVect = [self fetchRowAsArray]) { [theTable addObject:theVect]; } theTable = [NSArray arrayWithArray:theTable]; break; case MCPTypeDictionary : theTable = [NSMutableArray arrayWithCapacity:[self numOfRows]]; while (theVect = [self fetchRowAsDictionary]) { [theTable addObject:theVect]; } theTable = [NSArray arrayWithArray:theTable]; break; case MCPTypeFlippedArray : theTable = [NSMutableArray arrayWithCapacity:mNumOfFields]; for (i=0; i<mNumOfFields; i++) { [theTable addObject:[self fetchColAtIndex:i]]; } theTable = [NSArray arrayWithArray:theTable]; break; case MCPTypeFlippedDictionary : theTable = [NSMutableDictionary dictionaryWithCapacity:mNumOfFields]; if (mNames == nil) { [self fetchFieldsName]; } for (i=0; i<mNumOfFields; i++) { [theTable setObject:[self fetchColAtIndex:i] forKey:[mNames objectAtIndex:i]]; } theTable = [NSDictionary dictionaryWithDictionary:theTable]; break; default : NSLog (@"Unknown MCPReturnType : %d; return nil\n", (int)aType); theTable = nil; break; } mysql_row_seek(mResult,thePosition); return theTable; } @end Index: TO_DO =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/TO_DO,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** TO_DO 1 Jun 2002 20:58:18 -0000 1.1.2.1 --- TO_DO 3 Jun 2002 13:11:45 -0000 1.1.2.2 *************** *** 4,24 **** - Create a MCPNull object to reflect NULL columns values in retrieved table rows. - Create a "MCPNull" category for NSObject with only one method : isMCPNull (Being able to check if any object returned by SMySQL is a MCPNull) ++MCPResult: Centralising the field type recognition and filling of proper objects: ! - A single method doing the work : fetchRowAsType:(unsigned int) aType; - Wrapper for getting rows as Dictionnary or Array. Making a category for additional (optional) methods: - Getting a single column: ! - (NSArray *) fetchColWithIndex:(unsigned int) aCol; - (NSArray *) fetchColWithName:(NSString *) aColName; (Wrapping the previous one) - Adding bidimensional array data retrieval (in a Category?) ++MCPConnection Making a category to add some useful (but not mandatory) features: - (id) getFirstFieldFromQuery:(NSString *) query; (Frist column of first row of the result) ! - (id) getFirstRowFromQuery:(NSString *) query asType:(unsigned int) aType; (obvious) ! - (NSArray *) getAllRowsFromQuery:(NSString *) queryasType:(unsigned int) aType; (using 2D possibility of MCPResult) - (NSArray *) getQuery:(NSString *) query colWithIndex:(unsigned int) aCol; (Getting a single column form the query) - (NSArray *) getQuery:(NSString *) query colWithName:(NSString *) aColName; --- 4,29 ---- - Create a MCPNull object to reflect NULL columns values in retrieved table rows. - Create a "MCPNull" category for NSObject with only one method : isMCPNull (Being able to check if any object returned by SMySQL is a MCPNull) + -> Ok. + ++MCPResult: Centralising the field type recognition and filling of proper objects: ! - A single method doing the work : fetchRowAsType:(MCPReturnType) aType; - Wrapper for getting rows as Dictionnary or Array. + - Again with fetchTypesAsType: (MCPReturnType) aType; + wrappers + -> Ok. Making a category for additional (optional) methods: - Getting a single column: ! - (NSArray *) fetchColAtIndex:(unsigned int) aCol; - (NSArray *) fetchColWithName:(NSString *) aColName; (Wrapping the previous one) - Adding bidimensional array data retrieval (in a Category?) + -> Ok ++MCPConnection Making a category to add some useful (but not mandatory) features: - (id) getFirstFieldFromQuery:(NSString *) query; (Frist column of first row of the result) ! - (id) getFirstRowFromQuery:(NSString *) query asType:(MCPReturnType) aType; (obvious) ! - (NSArray *) getAllRowsFromQuery:(NSString *) query asType:(MCPReturnType) aType; (using 2D possibility of MCPResult) - (NSArray *) getQuery:(NSString *) query colWithIndex:(unsigned int) aCol; (Getting a single column form the query) - (NSArray *) getQuery:(NSString *) query colWithName:(NSString *) aColName; Index: SMySQL.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQL.h,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -C2 -d -r1.2.2.1 -r1.2.2.2 *** SMySQL.h 1 Jun 2002 20:58:18 -0000 1.2.2.1 --- SMySQL.h 3 Jun 2002 13:11:45 -0000 1.2.2.2 *************** *** 25,30 **** --- 25,33 ---- #import <Foundation/Foundation.h> + #import <SMySQL/SMySQLConstants.h> + #import <SMySQL/MCPNull.h> #import <SMySQL/MCPResult.h> #import <SMySQL/MCPConnection.h> + #import <SMySQL/MCPResultsPlus.h> #import "mysql.h" //#import <SMySQL/mysql.h> Index: MCPConnection.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPConnection.h,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** MCPConnection.h 1 Jun 2002 20:58:18 -0000 1.1.2.2 --- MCPConnection.h 3 Jun 2002 13:11:45 -0000 1.1.2.3 *************** *** 26,31 **** #import <Foundation/Foundation.h> #import "mysql.h" ! //#import <SMySQL/mysql.h> ! //#import <SMySQL/SMySQL.h> @class MCPResult; --- 26,31 ---- #import <Foundation/Foundation.h> #import "mysql.h" ! #import "SMySQLConstants.h" ! @class MCPResult; *************** *** 35,39 **** // Default socket (from the mysql.h used at compile time) ! extern NSString *kMCPConnectionDefaultSocket; // Added to mysql error code --- 35,39 ---- // Default socket (from the mysql.h used at compile time) ! extern const char *kMCPConnectionDefaultSocket; // Added to mysql error code *************** *** 51,54 **** --- 51,59 ---- + (NSStringEncoding) encodingForMySQLEncoding:(const char *) mysqlEncoding; + (NSStringEncoding) defaultMySQLEncoding; + + /*" + Class maintenance + "*/ + + (void) initialize; /*" Index: MCPConnection.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPConnection.m,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** MCPConnection.m 1 Jun 2002 20:58:18 -0000 1.1.2.2 --- MCPConnection.m 3 Jun 2002 13:11:45 -0000 1.1.2.3 *************** *** 28,32 **** const unsigned int kMCPConnectionDefaultOption = CLIENT_COMPRESS; ! NSString *kMCPConnectionDefaultSocket = MYSQL_UNIX_ADDR; const unsigned int kMCPConnection_Not_Inited = 1000; --- 28,32 ---- const unsigned int kMCPConnectionDefaultOption = CLIENT_COMPRESS; ! const char *kMCPConnectionDefaultSocket = MYSQL_UNIX_ADDR; const unsigned int kMCPConnection_Not_Inited = 1000; *************** *** 105,108 **** --- 105,120 ---- { return [MCPConnection encodingForMySQLEncoding:MYSQL_CHARSET]; + } + + + + (void) initialize + /*" + Initialize the class version to 2.0.0 + "*/ + { + if (self = [MCPConnection class]) { + [self setVersion:020000]; // Ma.Mi.Re -> MaMiRe + } + return; } Index: MCPResult.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPResult.h,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** MCPResult.h 1 Jun 2002 20:58:18 -0000 1.1.2.2 --- MCPResult.h 3 Jun 2002 13:11:46 -0000 1.1.2.3 *************** *** 26,31 **** #import <Foundation/Foundation.h> #import "mysql.h" ! //#import <SMySQL/mysql.h> ! //#import <SMySQL/SMySQL.h> @interface MCPResult : NSObject { --- 26,31 ---- #import <Foundation/Foundation.h> #import "mysql.h" ! #import "SMySQLConstants.h" ! @interface MCPResult : NSObject { *************** *** 34,38 **** --- 34,44 ---- NSDictionary *mMySQLLocales; /*"A Locales dictionary to define the locales of MySQL"*/ NSStringEncoding mEncoding; /*"The encoding used by MySQL server, to ISO-1 default"*/ + unsigned int mNumOfFields; /*"The number of fields in the result"*/ } + /*" + Class maintenance + "*/ + + + (void) initialize; /*" *************** *** 40,46 **** "*/ ! - (id)initWithMySQLPtr:(MYSQL *)mySQLPtr encoding:(NSStringEncoding)theEncoding; ! - (id)initWithResPtr:(MYSQL_RES *)mySQLResPtr encoding:(NSStringEncoding)theEncoding; ! - (id)init; /*" --- 46,52 ---- "*/ ! - (id) initWithMySQLPtr:(MYSQL *) mySQLPtr encoding:(NSStringEncoding) theEncoding; ! - (id) initWithResPtr:(MYSQL_RES *) mySQLResPtr encoding:(NSStringEncoding) theEncoding; ! - (id) init; /*" *************** *** 48,53 **** "*/ ! - (my_ulonglong)numOfRows; ! - (unsigned int)numOfFields; /*" --- 54,59 ---- "*/ ! - (my_ulonglong) numOfRows; ! - (unsigned int) numOfFields; /*" *************** *** 55,62 **** "*/ ! - (void)dataSeek:(my_ulonglong)row; ! - (NSDictionary *)fetchRowAsDictionary; ! - (NSArray *)fetchRowAsArray; /*" --- 61,69 ---- "*/ ! - (void) dataSeek:(my_ulonglong) row; ! - (id) fetchRowAsType:(MCPReturnType) aType; ! - (NSArray *) fetchRowAsArray; ! - (NSDictionary *) fetchRowAsDictionary; /*" *************** *** 64,79 **** "*/ ! - (NSArray *)fetchFieldsName; ! - (NSArray *)fetchTypesAsArray; ! - (NSDictionary *)fetchTypesAsDictionary; ! - (BOOL)isBlobAtIndex:(unsigned int)index; ! - (BOOL)isBlobForKey:(NSString *)key; /*" Utility method "*/ ! - (NSString *)description; /*" --- 71,87 ---- "*/ ! - (NSArray *) fetchFieldsName; ! - (id) fetchTypesAsType:(MCPReturnType) aType; ! - (NSArray *) fetchTypesAsArray; ! - (NSDictionary *) fetchTypesAsDictionary; ! - (BOOL) isBlobAtIndex:(unsigned int) index; ! - (BOOL) isBlobForKey:(NSString *) key; /*" Utility method "*/ ! - (NSString *) description; /*" *************** *** 81,91 **** "*/ ! - (void)dealloc; /*" Private methods, internam use only "*/ ! - (const char *)cStringFromString:(NSString *)theString; ! - (NSString *)stringWithCString:(const char *)theCString; @end --- 89,99 ---- "*/ ! - (void) dealloc; /*" Private methods, internam use only "*/ ! - (const char *) cStringFromString:(NSString *) theString; ! - (NSString *) stringWithCString:(const char *) theCString; @end Index: MCPResult.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPResult.m,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** MCPResult.m 1 Jun 2002 20:58:18 -0000 1.1.2.2 --- MCPResult.m 3 Jun 2002 13:11:46 -0000 1.1.2.3 *************** *** 25,28 **** --- 25,29 ---- #import "MCPConnection.h" + #import "MCPNull.h" #import "MCPResult.h" *************** *** 60,64 **** "*/ ! - (id)initWithMySQLPtr:(MYSQL *)mySQLPtr encoding:(NSStringEncoding)theEncoding /*" initialise a MCPResult, it is used internally by MCPConnection #{queryString:} method: the only proper way to get a running MCPResult object. --- 61,77 ---- "*/ ! + (void) initialize ! /*" ! Initialize the class version to 2.0.0 ! "*/ ! { ! if (self = [MCPResult class]) { ! [self setVersion:020000]; // Ma.Mi.Re -> MaMiRe ! } ! return; ! } ! ! ! - (id) initWithMySQLPtr:(MYSQL *) mySQLPtr encoding:(NSStringEncoding) theEncoding /*" initialise a MCPResult, it is used internally by MCPConnection #{queryString:} method: the only proper way to get a running MCPResult object. *************** *** 76,79 **** --- 89,98 ---- } mResult = mysql_store_result(mySQLPtr); + if (mResult) { + mNumOfFields = mysql_num_fields(mResult); + } + else { + mNumOfFields = 0; + } /* if (mResult == NULL) { *************** *** 89,93 **** ! - (id)initWithResPtr:(MYSQL_RES *)mySQLResPtr encoding:(NSStringEncoding)theEncoding /*" This metod it is used internally by MCPConnection object when it have already a MYSQL_RES object to initialise MCPResult object. --- 108,112 ---- ! - (id) initWithResPtr:(MYSQL_RES *) mySQLResPtr encoding:(NSStringEncoding) theEncoding /*" This metod it is used internally by MCPConnection object when it have already a MYSQL_RES object to initialise MCPResult object. *************** *** 107,110 **** --- 126,135 ---- } mResult = mySQLResPtr; + if (mResult) { + mNumOfFields = mysql_num_fields(mResult); + } + else { + mNumOfFields = 0; + } /* if (mResult == NULL) { *************** *** 119,123 **** } ! - (id)init /*" Empty init, normaly of NO use to the user, again, MCPResult should be made through calls to MCPConnection --- 144,148 ---- } ! - (id) init /*" Empty init, normaly of NO use to the user, again, MCPResult should be made through calls to MCPConnection *************** *** 137,145 **** mMySQLLocales = [[MCPConnection getMySQLLocales] retain]; } return self; } ! - (my_ulonglong)numOfRows /*" Return the number of rows selected by the query. --- 162,171 ---- mMySQLLocales = [[MCPConnection getMySQLLocales] retain]; } + mNumOfFields = 0; return self; } ! - (my_ulonglong) numOfRows /*" Return the number of rows selected by the query. *************** *** 153,169 **** ! - (unsigned int)numOfFields /*" ! Return the number of fields selected by the query. "*/ { if (mResult) { ! return mysql_num_fields(mResult); } ! return 0; } ! - (void)dataSeek:(my_ulonglong)row /*" Go to a precise row in the selected result. 0 is the very first row --- 179,195 ---- ! - (unsigned int) numOfFields /*" ! Return the number of fields selected by the query. As a side effect it forces an update of the number of fields. "*/ { if (mResult) { ! return mNumOfFields = mysql_num_fields(mResult); } ! return mNumOfFields = 0; } ! - (void) dataSeek:(my_ulonglong) row /*" Go to a precise row in the selected result. 0 is the very first row *************** *** 177,183 **** ! - (NSDictionary *)fetchRowAsDictionary /*" ! Return the next row of the result as a dictionary, the key being the field name, the object a proper object for handling the information in the field (NSString, NSNumber ...). "*/ { --- 203,211 ---- ! - (id) fetchRowAsType:(MCPReturnType) aType /*" ! Return the next row of the result as a collection of type defined by aType (namely MCPTypeArray or MCPTypeDictionary). Each field of the row is made into a proper object to hold the info (NSNumber, NSString...). ! ! This method returned directly the !{mutable} object generated while going through all the columns "*/ { *************** *** 186,200 **** MYSQL_FIELD *theField; int i; ! unsigned int theNumFields; ! NSMutableDictionary *theDict; ! if (mResult == NULL) { // If there is no results, returns nil, as after the last row... return nil; } - - if (mNames == NULL) { - [self fetchFieldsName]; - } theRow = mysql_fetch_row(mResult); --- 214,223 ---- MYSQL_FIELD *theField; int i; ! id theReturn; ! if (mResult == NULL) { // If there is no results, returns nil, as after the last row... return nil; } theRow = mysql_fetch_row(mResult); *************** *** 202,408 **** return nil; } - - // NSMutableDictionary *theDict = [NSMutableDictionary dictionaryWithCapacity:theNumFields]; ! theNumFields = [self numOfFields]; ! theDict = [NSMutableDictionary dictionaryWithCapacity:theNumFields]; ! theLengths = mysql_fetch_lengths(mResult); theField = mysql_fetch_fields(mResult); ! for (i=0; i<theNumFields; i++) { ! id theCurrentObj,theDataObj; ! char *theData = calloc(sizeof(char),theLengths[i]+1); ! memcpy(theData, theRow[i],theLengths[i]); ! theData[theLengths[i]] = '\0'; ! // NSLog (@"in fetchRowAsDictionary : field type is %d, for column %d", (int)theField[i].type, (int)i); ! switch (theField[i].type) { ! case FIELD_TYPE_TINY: ! case FIELD_TYPE_SHORT: ! case FIELD_TYPE_LONG: ! case FIELD_TYPE_INT24: ! case FIELD_TYPE_LONGLONG: ! theCurrentObj = [NSNumber numberWithLong:atol(theData)]; ! break; ! case FIELD_TYPE_DECIMAL: ! case FIELD_TYPE_FLOAT: ! case FIELD_TYPE_DOUBLE: ! theCurrentObj = [NSNumber numberWithDouble:atof(theData)]; ! break; ! case FIELD_TYPE_TIMESTAMP: // Indeed one should check which format it is (14,12...2) and get the corresponding format string // a switch on theLength[i] would do that... // Here it will crash if it's not default presentation : TIMESTAMP(14) ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y%m%d%H%M%S"]; ! break; ! case FIELD_TYPE_DATE: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d"]; ! break; ! case FIELD_TYPE_TIME: // Pass them back as string for the moment... not TIME object in Cocoa (so far) ! theCurrentObj = [NSString stringWithUTF8String:theData]; ! case FIELD_TYPE_DATETIME: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d %H:%M:%S"]; ! break; ! case FIELD_TYPE_YEAR: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y"]; ! break; ! case FIELD_TYPE_VAR_STRING: ! case FIELD_TYPE_STRING: ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! case FIELD_TYPE_TINY_BLOB: ! case FIELD_TYPE_BLOB: ! case FIELD_TYPE_MEDIUM_BLOB: ! case FIELD_TYPE_LONG_BLOB: ! theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! break; ! case FIELD_TYPE_SET: ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! case FIELD_TYPE_ENUM: ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! case FIELD_TYPE_NULL: ! theCurrentObj = nil; ! break; ! case FIELD_TYPE_NEWDATE: // Don't know what the format for this type is... ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; break; ! default: ! NSLog (@"in fetchRowAsDictionary : Unknown type : %d for column %d, send back a NSData object", (int)theField[i].type, (int)i); ! theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; break; } - [theDict setObject:theCurrentObj forKey:[mNames objectAtIndex:i]]; - free(theData); } ! ! return [NSDictionary dictionaryWithDictionary:theDict]; } ! - (NSArray *)fetchRowAsArray /*" Return the next row of the result as an array, the index in select field order, the object a proper object for handling the information in the field (NSString, NSNumber ...). "*/ { ! MYSQL_ROW theRow; ! unsigned long *theLengths; ! MYSQL_FIELD *theField; ! int i; ! unsigned int theNumFields; ! NSMutableArray* theArray; ! ! if (mResult == NULL) { ! // If there is no results, returns nil, as after the last row... ! return nil; } ! ! theRow = mysql_fetch_row(mResult); ! if (theRow == NULL) { return nil; } - // A row have been retrieved succesfully, put in in the dictionary - - theNumFields = [self numOfFields]; - theArray = [NSMutableArray arrayWithCapacity:theNumFields]; ! theLengths = mysql_fetch_lengths(mResult); ! theField = mysql_fetch_fields(mResult); ! for (i=0; i<theNumFields; i++) { ! id theCurrentObj,theDataObj; ! char *theData = calloc(sizeof(char),theLengths[i]+1); ! memcpy(theData, theRow[i],theLengths[i]); ! theData[theLengths[i]] = '\0'; ! // NSLog (@"in fetchRowAsArray : field type is %d, for column %d", (int)theField[i].type, (int)i); ! switch (theField[i].type) { ! case FIELD_TYPE_TINY: ! case FIELD_TYPE_SHORT: ! case FIELD_TYPE_LONG: ! case FIELD_TYPE_INT24: ! case FIELD_TYPE_LONGLONG: ! theCurrentObj = [NSNumber numberWithLong:atol(theData)]; ! break; ! case FIELD_TYPE_DECIMAL: ! case FIELD_TYPE_FLOAT: ! case FIELD_TYPE_DOUBLE: ! theCurrentObj = [NSNumber numberWithDouble:atof(theData)]; ! break; ! case FIELD_TYPE_TIMESTAMP: ! // Indeed one should check which format it is (14,12...2) and get the corresponding format string ! // a switch on theLength[i] would do that... ! // Here it will crash if it's not default presentation : TIMESTAMP(14) ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y%m%d%H%M%S"]; ! break; ! case FIELD_TYPE_DATE: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d"]; ! break; ! case FIELD_TYPE_TIME: ! // Pass them back as string for the moment... not TIME object in Cocoa (so far) ! theCurrentObj = [NSString stringWithUTF8String:theData]; ! case FIELD_TYPE_DATETIME: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d %H:%M:%S"]; ! break; ! case FIELD_TYPE_YEAR: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y"]; ! break; ! case FIELD_TYPE_VAR_STRING: ! case FIELD_TYPE_STRING: ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! case FIELD_TYPE_TINY_BLOB: ! case FIELD_TYPE_BLOB: ! case FIELD_TYPE_MEDIUM_BLOB: ! case FIELD_TYPE_LONG_BLOB: ! theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! break; ! case FIELD_TYPE_SET: ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! case FIELD_TYPE_ENUM: ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! case FIELD_TYPE_NULL: ! theCurrentObj = nil; ! break; ! case FIELD_TYPE_NEWDATE: ! // Don't know what the format for this type is... ! theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; ! [theCurrentObj autorelease]; ! break; ! default: ! NSLog (@"in fetchRowAsArray : Unknown type : %d for column %d, send back a NSData object", (int)theField[i].type, (int)i); ! theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! break; ! } ! [theArray addObject:theCurrentObj]; ! free(theData); } - - return [NSArray arrayWithArray:theArray]; } ! - (NSArray *)fetchFieldsName /*" Generate the mNames if not already generated, and return it. --- 225,377 ---- return nil; } ! switch (aType) { ! case MCPTypeArray: ! theReturn = [NSMutableArray arrayWithCapacity:mNumOfFields]; ! break; ! case MCPTypeDictionary: ! if (mNames == nil) { ! [self fetchFieldsName]; ! } ! theReturn = [NSMutableDictionary dictionaryWithCapacity:mNumOfFields]; ! break; ! default : ! NSLog (@"Unknown type : %d, will return an Array!\n", aType); ! theReturn = [NSMutableArray arrayWithCapacity:mNumOfFields]; ! break; ! } ! theLengths = mysql_fetch_lengths(mResult); theField = mysql_fetch_fields(mResult); ! for (i=0; i<mNumOfFields; i++) { ! id theCurrentObj; ! if (theRow[i] == NULL) { ! theCurrentObj = [NSNull null]; ! } ! else { ! char *theData = calloc(sizeof(char),theLengths[i]+1); ! memcpy(theData, theRow[i],theLengths[i]); ! theData[theLengths[i]] = '\0'; ! switch (theField[i].type) { ! case FIELD_TYPE_TINY: ! case FIELD_TYPE_SHORT: ! case FIELD_TYPE_LONG: ! case FIELD_TYPE_INT24: ! case FIELD_TYPE_LONGLONG: ! theCurrentObj = [NSNumber numberWithLong:atol(theData)]; ! break; ! case FIELD_TYPE_DECIMAL: ! case FIELD_TYPE_FLOAT: ! case FIELD_TYPE_DOUBLE: ! theCurrentObj = [NSNumber numberWithDouble:atof(theData)]; ! break; ! case FIELD_TYPE_TIMESTAMP: // Indeed one should check which format it is (14,12...2) and get the corresponding format string // a switch on theLength[i] would do that... // Here it will crash if it's not default presentation : TIMESTAMP(14) ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y%m%d%H%M%S"]; ! break; ! case FIELD_TYPE_DATE: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d"]; ! break; ! case FIELD_TYPE_TIME: // Pass them back as string for the moment... not TIME object in Cocoa (so far) ! theCurrentObj = [NSString stringWithUTF8String:theData]; ! case FIELD_TYPE_DATETIME: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d %H:%M:%S"]; ! break; ! case FIELD_TYPE_YEAR: ! theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y"]; ! break; ! case FIELD_TYPE_VAR_STRING: ! case FIELD_TYPE_STRING: ! theCurrentObj = [self stringWithCString:theData]; ! break; ! case FIELD_TYPE_TINY_BLOB: ! case FIELD_TYPE_BLOB: ! case FIELD_TYPE_MEDIUM_BLOB: ! case FIELD_TYPE_LONG_BLOB: ! theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! break; ! case FIELD_TYPE_SET: ! theCurrentObj = [self stringWithCString:theData]; ! break; ! case FIELD_TYPE_ENUM: ! theCurrentObj = [self stringWithCString:theData]; ! break; ! case FIELD_TYPE_NULL: ! theCurrentObj = nil; ! break; ! case FIELD_TYPE_NEWDATE: // Don't know what the format for this type is... ! theCurrentObj = [self stringWithCString:theData]; ! break; ! default: ! NSLog (@"in fetchRowAsDictionary : Unknown type : %d for column %d, send back a NSData object", (int)theField[i].type, (int)i); ! theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; ! break; ! } ! free(theData); ! } ! switch (aType) { ! case MCPTypeArray : ! [theReturn addObject:theCurrentObj]; break; ! case MCPTypeDictionary : ! [theReturn setObject:theCurrentObj forKey:[mNames objectAtIndex:i]]; ! break; ! default : ! [theReturn addObject:theCurrentObj]; break; } } ! ! return theReturn; } ! ! - (NSArray *) fetchRowAsArray /*" Return the next row of the result as an array, the index in select field order, the object a proper object for handling the information in the field (NSString, NSNumber ...). + + Just a !{typed} wrapper for method #{fetchRosAsType:} (with arg MCPTypeArray). + + + NB: Returned object is immutable. "*/ { ! NSMutableArray *theArray = [self fetchRowAsType:MCPTypeArray]; ! if (theArray) { ! return [NSArray arrayWithArray:theArray]; } ! else { return nil; } + } ! - (NSDictionary *) fetchRowAsDictionary ! /*" ! Return the next row of the result as a dictionary, the key being the field name, the object a proper object for handling the information in the field (NSString, NSNumber ...). ! Just a !{typed} wrapper for method #{fetchRosAsType:} (with arg MCPTypeDictionary). ! NB: Returned object is immutable. ! "*/ ! { ! NSMutableDictionary *theDict = [self fetchRowAsType:MCPTypeDictionary]; ! if (theDict) { ! return [NSDictionary dictionaryWithDictionary:theDict]; ! } ! else { ! return nil; } } ! ! - (NSArray *) fetchFieldsName /*" Generate the mNames if not already generated, and return it. *************** *** 440,462 **** } ! - (NSArray *)fetchTypesAsArray /*" ! Return an array of the fields' types. "*/ { - unsigned int theNumFields; int i; ! NSMutableArray *theTypesArray; MYSQL_FIELD *theField; if (mResult == NULL) { // If no results, give an empty array. Maybe it's better to give a nil pointer? ! return ([NSArray array]); } ! ! theNumFields = [self numOfFields]; ! theTypesArray = [NSMutableArray arrayWithCapacity: theNumFields]; ! theField = mysql_fetch_fields(mResult); ! for (i=0; i<theNumFields; i++) { NSString *theType; switch (theField[i].type) { --- 409,446 ---- } ! ! - (id) fetchTypesAsType:(MCPReturnType) aType /*" ! Return a collection of the fields's type. The type of collection is choosen by the aType variable (MCPTypeArray or MCPTypeDictionary). ! ! This method returned directly the !{mutable} object generated while going through all the columns "*/ { int i; ! id theTypes; MYSQL_FIELD *theField; if (mResult == NULL) { // If no results, give an empty array. Maybe it's better to give a nil pointer? ! return nil; } ! ! switch (aType) { ! case MCPTypeArray: ! theTypes = [NSMutableArray arrayWithCapacity:mNumOfFields]; ! break; ! case MCPTypeDictionary: ! if (mNames == nil) { ! [self fetchFieldsName]; ! } ! theTypes = [NSMutableDictionary dictionaryWithCapacity:mNumOfFields]; ! break; ! default : ! NSLog (@"Unknown type : %d, will return an Array!\n", aType); ! theTypes = [NSMutableArray arrayWithCapacity:mNumOfFields]; ! break; ! } ! theField = mysql_fetch_fields(mResult); ! for (i=0; i<mNumOfFields; i++) { NSString *theType; switch (theField[i].type) { *************** *** 535,651 **** break; } ! [theTypesArray addObject:theType]; } ! ! return ([NSArray arrayWithArray:theTypesArray]); } ! - (NSDictionary*)fetchTypesAsDictionary /*" ! Return a dictionnary of the fields' types (keys are the fields' names). "*/ { ! unsigned int theNumFields; ! int i; ! NSMutableDictionary *theTypesDict; ! MYSQL_FIELD *theField; ! ! if (mResult == NULL) { ! // If no results, give an empty array. Maybe it's better to give a nil pointer? ! return ([NSDictionary dictionary]); } ! ! if (mNames == NULL) { ! [self fetchFieldsName]; } ! theNumFields = [self numOfFields]; ! theTypesDict = [NSMutableDictionary dictionaryWithCapacity: theNumFields]; ! theField = mysql_fetch_fields(mResult); ! for (i=0; i<theNumFields; i++) { ! NSString *theType; ! switch (theField[i].type) { ! case FIELD_TYPE_TINY: ! theType = @"tiny"; ! break; ! case FIELD_TYPE_SHORT: ! theType = @"short"; ! break; ! case FIELD_TYPE_LONG: ! theType = @"long"; ! break; ! case FIELD_TYPE_INT24: ! theType = @"int24"; ! break; ! case FIELD_TYPE_LONGLONG: ! theType = @"longlong"; ! break; ! case FIELD_TYPE_DECIMAL: ! theType = @"decimal"; ! break; ! case FIELD_TYPE_FLOAT: ! theType = @"float"; ! break; ! case FIELD_TYPE_DOUBLE: ! theType = @"double"; ! break; ! case FIELD_TYPE_TIMESTAMP: ! theType = @"timestamp"; ! break; ! case FIELD_TYPE_DATE: ! theType = @"date"; ! break; ! case FIELD_TYPE_TIME: ! theType = @"time"; ! break; ! case FIELD_TYPE_DATETIME: ! theType = @"datetime"; ! break; ! case FIELD_TYPE_YEAR: ! theType = @"year"; ! break; ! case FIELD_TYPE_VAR_STRING: ! theType = @"varstring"; ! break; ! case FIELD_TYPE_STRING: ! theType = @"string"; ! break; ! case FIELD_TYPE_TINY_BLOB: ! theType = @"tinyblob"; ! break; ! case FIELD_TYPE_BLOB: ! theType = @"blob"; ! break; ! case FIELD_TYPE_MEDIUM_BLOB: ! theType = @"mediumblob"; ! break; ! case FIELD_TYPE_LONG_BLOB: ! theType = @"longblob"; ! break; ! case FIELD_TYPE_SET: ! theType = @"set"; ! break; ! case FIELD_TYPE_ENUM: ! theType = @"enum"; ! break; ! case FIELD_TYPE_NULL: ! theType = @"null"; ! break; ! case FIELD_TYPE_NEWDATE: ! theType = @"newdate"; ! break; ! default: ! theType = @"unknown"; ! NSLog (@"in fetchTypesAsDictionary : Unknown type for column %d of the MCPResult, type = %d", (int)i, (int)theField[i].type); ! break; ! } ! [theTypesDict setObject:theType forKey:[mNames objectAtIndex:i]]; } - - return ([NSDictionary dictionaryWithDictionary:theTypesDict]); } ! - (BOOL)isBlobAtIndex:(unsigned int)index /*" Return YES if the field with the given index is a BLOB. It should be used to discriminates between BLOBs and TEXTs. --- 519,574 ---- break; } ! switch (aType) { ! case MCPTypeArray : ! [theTypes addObject:theType]; ! break; ! case MCPTypeDictionary : ! [theTypes setObject:theType forKey:[mNames objectAtIndex:i]]; ! break; ! default : ! [theTypes addObject:theType]; ! break; ! } } ! ! return theTypes; } ! ! - (NSArray *) fetchTypesAsArray /*" ! Return an array of the fields' types. ! ! NB: Returned object is immutable. "*/ { ! NSMutableArray *theArray = [self fetchTypesAsType:MCPTypeArray]; ! if (theArray) { ! return [NSArray arrayWithArray:theArray]; } ! else { ! return nil; } + } ! - (NSDictionary*) fetchTypesAsDictionary ! /*" ! Return a dictionnary of the fields' types (keys are the fields' names). ! ! NB: Returned object is immutable. ! "*/ ! { ! NSMutableDictionary *theDict = [self fetchTypesAsType:MCPTypeDictionary]; ! if (theDict) { ! return [NSDictionary dictionaryWithDictionary:theDict]; ! } ! else { ! return nil; } } ! ! - (BOOL) isBlobAtIndex:(unsigned int) index /*" Return YES if the field with the given index is a BLOB. It should be used to discriminates between BLOBs and TEXTs. *************** *** 685,689 **** } ! - (BOOL)isBlobForKey:(NSString *)key /*" Return YES if the field (by name) with the given index is a BLOB. It should be used to discriminates between BLOBs and TEXTs. --- 608,612 ---- } ! - (BOOL) isBlobForKey:(NSString *) key /*" Return YES if the field (by name) with the given index is a BLOB. It should be used to discriminates between BLOBs and TEXTs. *************** *** 728,732 **** ! - (NSString *)description /*" Return a (long) string containing the table of results, first line being the fields name, next line(s) the row(s). Useful to have NSLog logging a MCPResult (example). --- 651,655 ---- ! - (NSString *) description /*" Return a (long) string containing the table of results, first line being the fields name, next line(s) the row(s). Useful to have NSLog logging a MCPResult (example). *************** *** 738,750 **** else { NSMutableString *theString = [NSMutableString stringWithCapacity:0]; ! int i, numFields; NSArray *theRow; MYSQL_ROW_OFFSET thePosition; // First line, saying we are displaying a MCPResult ! [theString appendString:@"MCPResult:\n"]; // Second line: the field names, tab separated [self fetchFieldsName]; ! for (i=0; i<((numFields = [mNames count])-1); i++) { [theString appendFormat:@"%@\t", [mNames objectAtIndex:i]]; } --- 661,673 ---- else { NSMutableString *theString = [NSMutableString stringWithCapacity:0]; ! int i; NSArray *theRow; MYSQL_ROW_OFFSET thePosition; // First line, saying we are displaying a MCPResult ! [theString appendFormat:@"MCPResult: (encoding : %d, dim %d x %d)\n", (long)mEncoding, (long)mNumOfFields, (long)[self numOfRows]]; // Second line: the field names, tab separated [self fetchFieldsName]; ! for (i=0; i<(mNumOfFields-1); i++) { [theString appendFormat:@"%@\t", [mNames objectAtIndex:i]]; } *************** *** 754,758 **** [self dataSeek:0]; while (theRow = [self fetchRowAsArray]) { ! for (i=0; i<(numFields - 1); i++) { [theString appendFormat:@"%@\t", [theRow objectAtIndex:i]]; } --- 677,681 ---- [self dataSeek:0]; while (theRow = [self fetchRowAsArray]) { ! for (i=0; i<(mNumOfFields - 1); i++) { [theString appendFormat:@"%@\t", [theRow objectAtIndex:i]]; } *************** *** 766,770 **** ! - (void)dealloc /* Do one really needs an explanation for this method? Which by the way you should not use... --- 689,693 ---- ! - (void) dealloc /* Do one really needs an explanation for this method? Which by the way you should not use... *************** *** 785,789 **** } ! - (const char *)cStringFromString:(NSString *)theString /*" For internal use only. Transform a NSString to a C type string (ended with \0) using ethe character set from the MCPConnection. --- 708,712 ---- } ! - (const char *) cStringFromString:(NSString *) theString /*" For internal use only. Transform a NSString to a C type string (ended with \0) using ethe character set from the MCPConnection. *************** *** 803,807 **** ! - (NSString *)stringWithCString:(const char *)theCString /*" Return a NSString from a C style string encoded with the character set of theMCPConnection. --- 726,730 ---- ! - (NSString *) stringWithCString:(const char *) theCString /*" Return a NSString from a C style string encoded with the character set of theMCPConnection. |
From: Serge C. <ser...@us...> - 2002-06-03 13:11:52
|
Update of /cvsroot/mysql-cocoa/SMySQL/SMySQL_Test In directory usw-pr-cvs1:/tmp/cvs-serv12478 Modified Files: Tag: version-2 main2.m Log Message: -Added support for NULL fields in the results. -Easier to maintain methods for retrieving row and types information -Added a MCPResultPlus category, for extra methods to handle and get result rows and column (per column, and 2D) Serge Cohen; MySQL Cocoa project, 2002-06-03. Index: main2.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQL_Test/Attic/main2.m,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** main2.m 2 Jun 2002 12:48:45 -0000 1.1.2.1 --- main2.m 3 Jun 2002 13:11:45 -0000 1.1.2.2 *************** *** 44,47 **** --- 44,48 ---- connection = [[MCPConnection alloc] initToHost:@"localhost" withLogin:@"ObjC" password:@"MySQL_class" usingPort:0]; [connection selectDB:@"test_mysqlclass"]; + result = [connection queryString:@"select * from test1"]; count = [result numOfFields]; *************** *** 63,66 **** --- 64,68 ---- NSLog (@"Here is the NSLog of a MCPResult : \n%@", result); // [result release]; + result = [connection queryString:@"select test1_id, test1_key from test1 where test1_id=1"]; |
From: Serge C. <ser...@us...> - 2002-06-02 12:48:48
|
Update of /cvsroot/mysql-cocoa/SMySQL/SMySQL_Test In directory usw-pr-cvs1:/tmp/cvs-serv7467 Added Files: Tag: version-2 gpl.txt main2.m Log Message: Added the source (and licence) for SMySQL_Test (of SMySQL.pbproj). Serge Cohen; MySQL Cocoa project, 2002-06-01. --- NEW FILE: gpl.txt --- GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. <signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. --- NEW FILE: main2.m --- // // SMySQL_test application // // Created by serge cohen (ser...@m4...) on Sat Dec 08 2001. // Copyright (c) 2001 MySQL Cocoa project. // // This code is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 of the License, or any later version. // // This code is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // For a copy of the GNU General Public License, visit <http://www.gnu.org/> or // write to the Free Software Foundation, Inc., 59 Temple Place--Suite 330, // Boston, MA 02111-1307, USA. // // More info at <http://mysql-cocoa.sourceforge.net/> // // /* This is a simple application to test the framework : SMySQL. * this application needs a server to exist on the localhost, * user : ObjC password : MySQL_class * * The program select the database : test_mysqlclass * Then display the content of table : test1. */ #import <Foundation/Foundation.h> #import <SMySQL/SMySQL.h> int main (int argc, const char * argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; MCPConnection *connection; MCPResult *result; NSArray *names, *types; NSDictionary *row; unsigned int count, i; // insert code here... connection = [[MCPConnection alloc] initToHost:@"localhost" withLogin:@"ObjC" password:@"MySQL_class" usingPort:0]; [connection selectDB:@"test_mysqlclass"]; result = [connection queryString:@"select * from test1"]; count = [result numOfFields]; names = [result fetchFieldsName]; types = [result fetchTypesAsArray]; for (i=0; i<count; i++) { NSLog(@" Column : %d of type : %@ has for name : %@\n", (i+1), [types objectAtIndex:i], [names objectAtIndex:i]); } while (row = [result fetchRowAsDictionary]) { for (i=0; i<count; i++) { NSString *name = [names objectAtIndex:i]; NSLog(@"%@ : %@\n", name, [row objectForKey:name]); if ([result isBlobAtIndex:i]) { NSString *theString = [result stringWithCString:[[row objectForKey:name] bytes]]; NSLog(@" as string : %@\n",theString); } } } NSLog (@"Here is the NSLog of a MCPResult : \n%@", result); // [result release]; result = [connection queryString:@"select test1_id, test1_key from test1 where test1_id=1"]; [result fetchFieldsName]; NSLog (@"Here is theNSLog of a MCPResult %@", result); result = [connection listFieldsFromTable:@"test1" like:nil]; [result fetchFieldsName]; NSLog (@"Here is theNSLog of a MCPResult (listFields:nil forTable:test1) %@", result); result = [connection listFieldsFromTable:@"test1"]; [result fetchFieldsName]; NSLog (@"Here is theNSLog of a MCPResult (listFields:nil forTable:test1) %@", result); result = [connection listDBs]; [result fetchFieldsName]; NSLog (@"Here is the NSLog of a MCPResult (listDBs) : \n%@", result); result = [connection listDBsLike:@"test\\_%%"]; [result fetchFieldsName]; NSLog (@"Here is the NSLog of a MCPResult (listDBs:test\\_%%) : \n%@", result); result = [connection listTables]; [result fetchFieldsName]; NSLog (@"Here is the NSLog of a MCPResult (listTables) : \n%@", result); NSLog (@"Here comes the server information : %@\n", [connection serverInfo]); [connection queryString:@"select blablabla error"]; NSLog (@"Here comes the last error information : %@\n", [connection getLastErrorMessage]); [connection release]; [pool release]; return 0; } |
From: Serge C. <ser...@us...> - 2002-06-02 12:46:19
|
Update of /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj In directory usw-pr-cvs1:/tmp/cvs-serv7013a/SMySQL.pbproj Modified Files: Tag: version-2 cohen.pbxuser project.pbxproj Log Message: Added a target (and proper code) to have the Test application in the same project as the framework. Serge Cohen; MySQL Coca project, 2002-06-01 Index: cohen.pbxuser =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj/cohen.pbxuser,v retrieving revision 1.13.2.1 retrieving revision 1.13.2.2 diff -C2 -d -r1.13.2.1 -r1.13.2.2 *** cohen.pbxuser 1 Jun 2002 20:59:00 -0000 1.13.2.1 --- cohen.pbxuser 2 Jun 2002 12:46:16 -0000 1.13.2.2 *************** *** 3,7 **** 0867D690FE84028FC02AAC07 = { activeBuildStyle = F51A62D4022D7B3301952E7A; ! activeTarget = F51A62D7022D7C2A01952E7A; addToTargets = ( ); --- 3,7 ---- 0867D690FE84028FC02AAC07 = { activeBuildStyle = F51A62D4022D7B3301952E7A; ! activeTarget = F59C3D3D02AA458C017B4675; addToTargets = ( ); *************** *** 10,21 **** perUserDictionary = { PBXWorkspaceConfiguration = { ! ContentSize = "{971, 647}"; LeftSlideOut = { ActiveTab = 0; ! Frame = "{{0, 23}, {971, 624}}"; Split0 = { ! Frame = "{{232, 0}, {739, 624}}"; Split0 = { ! Frame = "{{0, 24}, {739, 600}}"; }; SplitCount = 1; --- 10,21 ---- perUserDictionary = { PBXWorkspaceConfiguration = { ! ContentSize = "{967, 573}"; LeftSlideOut = { ActiveTab = 0; ! Frame = "{{0, 23}, {967, 550}}"; Split0 = { ! Frame = "{{232, 0}, {735, 550}}"; Split0 = { ! Frame = "{{0, 24}, {735, 526}}"; }; SplitCount = 1; *************** *** 46,62 **** }; Tab1 = { ! Frame = "{{0, 0}, {484, 208}}"; LauncherConfigVersion = 3; Runner = { ! Frame = "{{0, 0}, {484, 208}}"; }; }; Tab2 = { ! BuildMessageFrame = "{{0, 0}, {741, 95}}"; ! BuildTranscriptFrame = "{{0, 104}, {741, 90}}"; ! Frame = "{{0, 0}, {739, 192}}"; }; Tab3 = { ! Frame = "{{0, 0}, {739, 295}}"; }; TabCount = 4; --- 46,62 ---- }; Tab1 = { ! Frame = "{{0, 0}, {735, 208}}"; LauncherConfigVersion = 3; Runner = { ! Frame = "{{0, 0}, {735, 208}}"; }; }; Tab2 = { ! BuildMessageFrame = "{{0, 0}, {745, 95}}"; ! BuildTranscriptFrame = "{{0, 104}, {745, 90}}"; ! Frame = "{{0, 0}, {743, 192}}"; }; Tab3 = { ! Frame = "{{0, 0}, {735, 295}}"; }; TabCount = 4; *************** *** 64,68 **** SplitCount = 1; Tab0 = { ! Frame = "{{0, 0}, {208, 624}}"; }; Tab1 = { --- 64,68 ---- SplitCount = 1; Tab0 = { ! Frame = "{{0, 0}, {208, 550}}"; }; Tab1 = { *************** *** 76,85 **** }; Tab3 = { ! Frame = "{{0, 0}, {200, 624}}"; Split0 = { ! Frame = "{{0, 0}, {200, 300}}"; }; Split1 = { ! Frame = "{{0, 309}, {200, 315}}"; }; SplitCount = 2; --- 76,85 ---- }; Tab3 = { ! Frame = "{{0, 0}, {200, 550}}"; Split0 = { ! Frame = "{{0, 0}, {200, 263}}"; }; Split1 = { ! Frame = "{{0, 272}, {200, 278}}"; }; SplitCount = 2; *************** *** 90,94 **** TabCount = 5; }; ! WindowLocation = "{34, 32}"; }; }; --- 90,94 ---- TabCount = 5; }; ! WindowLocation = "{29, 73}"; }; }; *************** *** 143,146 **** --- 143,171 ---- customExecs = { }; + }; + F59C3D3D02AA458C017B4675 = { + activeExec = 0; + customExecs = { + }; + targetExecs = { + macosx = ( + F59C3D4602AA458C017B4675, + ); + }; + }; + F59C3D4602AA458C017B4675 = { + activeArgIndex = 2147483647; + argumentStrings = ( + ); + debuggerPlugin = GDBDebugging; + dylibVariantSuffix = ""; + enableDebugStr = 1; + environmentEntries = ( + ); + isa = PBXExecutable; + shlibInfoDictList = ( + ); + sourceDirectories = ( + ); }; } Index: project.pbxproj =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj/project.pbxproj,v retrieving revision 1.13.2.1 retrieving revision 1.13.2.2 diff -C2 -d -r1.13.2.1 -r1.13.2.2 *** project.pbxproj 1 Jun 2002 20:59:00 -0000 1.13.2.1 --- project.pbxproj 2 Jun 2002 12:46:16 -0000 1.13.2.2 *************** *** 40,43 **** --- 40,44 ---- F51A62D6022D7C2901952E7A, F5649F0D023FDCA201D04C4B, + F59C3D3C02AA458C017B4675, ); isa = PBXGroup; *************** *** 75,78 **** --- 76,80 ---- F51A62D7022D7C2A01952E7A, F5649F0E023FDCA201D04C4B, + F59C3D3D02AA458C017B4675, ); }; *************** *** 86,89 **** --- 88,92 ---- 0867D69AFE84028FC02AAC07, 034768DFFF38A50411DB9C8B, + F59C3CF302AA3EFF017B4675, ); isa = PBXGroup; *************** *** 118,122 **** DYLIB_COMPATIBILITY_VERSION = 2.0.0; DYLIB_CURRENT_VERSION = 2.0.0; ! FRAMEWORK_SEARCH_PATHS = ""; FRAMEWORK_VERSION = A; HEADER_SEARCH_PATHS = ""; --- 121,125 ---- DYLIB_COMPATIBILITY_VERSION = 2.0.0; DYLIB_CURRENT_VERSION = 2.0.0; ! FRAMEWORK_SEARCH_PATHS = /Users/cohen/Library/Frameworks; FRAMEWORK_VERSION = A; HEADER_SEARCH_PATHS = ""; *************** *** 371,374 **** --- 374,409 ---- refType = 4; }; + F516627002AA484701A89878 = { + children = ( + F59C3D1002AA3EFF017B4675, + F59C3D1102AA3EFF017B4675, + ); + isa = PBXGroup; + name = "Sources etc."; + refType = 4; + }; + F516627102AA484701A89878 = { + children = ( + ); + isa = PBXGroup; + name = Products; + refType = 4; + }; + F516627202AA488F01A89878 = { + fileRef = F59C3D3902AA42C0017B4675; + isa = PBXBuildFile; + settings = { + }; + }; + F516627302AA488F01A89878 = { + fileRef = F59C3D3802AA42C0017B4675; + isa = PBXBuildFile; + settings = { + }; + }; + F516627402AA48F201A89878 = { + isa = PBXTargetDependency; + target = 0867D69CFE84028FC02AAC07; + }; F51A62D4022D7B3301952E7A = { buildRules = ( *************** *** 2044,2047 **** --- 2079,2193 ---- shellPath = /bin/sh; shellScript = "MKDIRS=\"mkdir -p\"\nAUTODOC=/usr/local/bin/autodoc\nAUTODOC_FLAGS=\"-copydocs -timestamp -allclasses\"\nAUTODOC_FORMAT=html\nAUTODOC_LANGUAGE=English\nexport AD_COPYRIGHT=\"MySQL Cocoa Project\"\n\n# If autodoc is not installed, we quit without any error\ntest -x $AUTODOC || exit 0\n\nPUBLIC_DOC_INSTALLDIR=\"$SYMROOT/$PRODUCT_NAME.framework/Resources/$AUTODOC_LANGUAGE.lproj/Documentation\"\n\n# We need to write down file names here\nAUTODOC_FILES=\"MCPConnection.h MCPResult.h\"\nAUTODOC_DOCDIR=\"$PUBLIC_DOC_INSTALLDIR\"\n\nOTHER_AUTODOC_FLAGS=\"-typedirs -allclasses -combine -force -nosingles\"\n\nALL_AUTODOC_FLAGS=\"$AUTODOC_FLAGS $OTHER_AUTODOC_FLAGS\"\n\n$MKDIRS $PUBLIC_DOC_INSTALLDIR\n$AUTODOC $ALL_AUTODOC_FLAGS -format $AUTODOC_FORMAT -dest $AUTODOC_DOCDIR $AUTODOC_FILES\n"; + }; + F59C3CF302AA3EFF017B4675 = { + children = ( + F516627002AA484701A89878, + F59C3D3702AA41FD017B4675, + F516627102AA484701A89878, + ); + isa = PBXGroup; + path = SMySQL_test; + refType = 2; + }; + F59C3D1002AA3EFF017B4675 = { + isa = PBXFileReference; + path = gpl.txt; + refType = 4; + }; + F59C3D1102AA3EFF017B4675 = { + isa = PBXFileReference; + path = main2.m; + refType = 4; + }; + F59C3D3702AA41FD017B4675 = { + children = ( + F59C3D3902AA42C0017B4675, + F59C3D3802AA42C0017B4675, + ); + isa = PBXGroup; + name = Frameworks; + refType = 4; + }; + F59C3D3802AA42C0017B4675 = { + isa = PBXFrameworkReference; + name = SMySQL.framework; + path = /Users/cohen/Library/Frameworks/SMySQL.framework; + refType = 0; + }; + F59C3D3902AA42C0017B4675 = { + isa = PBXFrameworkReference; + name = Foundation.framework; + path = /System/Library/Frameworks/Foundation.framework; + refType = 0; + }; + F59C3D3C02AA458C017B4675 = { + isa = PBXExecutableFileReference; + path = SMySQL_Test; + refType = 3; + }; + F59C3D3D02AA458C017B4675 = { + buildPhases = ( + F59C3D3F02AA458C017B4675, + F59C3D4002AA458C017B4675, + F59C3D4202AA458C017B4675, + F59C3D4502AA458C017B4675, + ); + buildSettings = { + FRAMEWORK_SEARCH_PATHS = /Users/cohen/Library/Frameworks; + OPTIMIZATION_CFLAGS = "-O0"; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = SMySQL_Test; + REZ_EXECUTABLE = YES; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + }; + dependencies = ( + F516627402AA48F201A89878, + ); + isa = PBXToolTarget; + name = SMySQL_Test; + productInstallPath = /usr/local/bin; + productName = SMySQL_Test; + productReference = F59C3D3C02AA458C017B4675; + shouldUseHeadermap = 0; + }; + F59C3D3F02AA458C017B4675 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXHeadersBuildPhase; + name = Headers; + }; + F59C3D4002AA458C017B4675 = { + buildActionMask = 2147483647; + files = ( + F59C3D4102AA458C017B4675, + ); + isa = PBXSourcesBuildPhase; + name = Sources; + }; + F59C3D4102AA458C017B4675 = { + fileRef = F59C3D1102AA3EFF017B4675; + isa = PBXBuildFile; + settings = { + }; + }; + F59C3D4202AA458C017B4675 = { + buildActionMask = 2147483647; + files = ( + F516627202AA488F01A89878, + F516627302AA488F01A89878, + ); + isa = PBXFrameworksBuildPhase; + name = "Frameworks & Libraries"; + }; + F59C3D4502AA458C017B4675 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + name = "ResourceManager Resources"; }; F5C0D59002884F280172C088 = { |
From: Serge C. <ser...@us...> - 2002-06-02 12:44:28
|
Update of /cvsroot/mysql-cocoa/SMySQL/SMySQL_Test In directory usw-pr-cvs1:/tmp/cvs-serv6907/SMySQL_Test Log Message: Directory /cvsroot/mysql-cocoa/SMySQL/SMySQL_Test added to the repository --> Using per-directory sticky tag `version-2' |
From: Serge C. <ser...@us...> - 2002-06-01 20:59:03
|
Update of /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj In directory usw-pr-cvs1:/tmp/cvs-serv2193 Modified Files: Tag: version-2 project.pbxproj cohen.pbxuser Log Message: Modified classes to be: MCPConnection MCPResult Added a TO_DO, updated the README file (fom within the project). Serge Cohen; MySQL Cocoa project, 2002-06-01.... Index: project.pbxproj =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj/project.pbxproj,v retrieving revision 1.13 retrieving revision 1.13.2.1 diff -C2 -d -r1.13 -r1.13.2.1 *** project.pbxproj 15 May 2002 11:07:39 -0000 1.13 --- project.pbxproj 1 Jun 2002 20:59:00 -0000 1.13.2.1 *************** *** 79,82 **** --- 79,83 ---- 0867D691FE84028FC02AAC07 = { children = ( + F5F6CECD02A6946E015D9B03, F51B527E01CA905F0130DCEA, F5165EC301C50B3A0116CAC1, *************** *** 115,120 **** ); buildSettings = { ! DYLIB_COMPATIBILITY_VERSION = 1.0.0; ! DYLIB_CURRENT_VERSION = 0.7.0; FRAMEWORK_SEARCH_PATHS = ""; FRAMEWORK_VERSION = A; --- 116,121 ---- ); buildSettings = { ! DYLIB_COMPATIBILITY_VERSION = 2.0.0; ! DYLIB_CURRENT_VERSION = 2.0.0; FRAMEWORK_SEARCH_PATHS = ""; FRAMEWORK_VERSION = A; *************** *** 161,167 **** <string>????</string> <key>CFBundleVersion</key> ! <string>0.7.0d1</string> <key>NSPrincipalClass</key> ! <string>SMySQLConnection</string> </dict> </plist> --- 162,168 ---- <string>????</string> <key>CFBundleVersion</key> ! <string>2.0.0d1</string> <key>NSPrincipalClass</key> ! <string>MCPConnection</string> </dict> </plist> *************** *** 279,298 **** F5165EB701C50A5A0116CAC1 = { isa = PBXFileReference; ! path = SMySQLConnection.h; refType = 4; }; F5165EB801C50A5A0116CAC1 = { isa = PBXFileReference; ! path = SMySQLConnection.m; refType = 4; }; F5165EB901C50A5A0116CAC1 = { isa = PBXFileReference; ! path = SMySQLResult.h; refType = 4; }; F5165EBA01C50A5A0116CAC1 = { isa = PBXFileReference; ! path = SMySQLResult.m; refType = 4; }; --- 280,299 ---- F5165EB701C50A5A0116CAC1 = { isa = PBXFileReference; ! path = MCPConnection.h; refType = 4; }; F5165EB801C50A5A0116CAC1 = { isa = PBXFileReference; ! path = MCPConnection.m; refType = 4; }; F5165EB901C50A5A0116CAC1 = { isa = PBXFileReference; ! path = MCPResult.h; refType = 4; }; F5165EBA01C50A5A0116CAC1 = { isa = PBXFileReference; ! path = MCPResult.m; refType = 4; }; *************** *** 409,414 **** ); buildSettings = { ! DYLIB_COMPATIBILITY_VERSION = 1.0.0; ! DYLIB_CURRENT_VERSION = 0.7.0; FRAMEWORK_VERSION = A; HEADER_SEARCH_PATHS = mysqlclient_source/headers; --- 410,415 ---- ); buildSettings = { ! DYLIB_COMPATIBILITY_VERSION = 2.0.0; ! DYLIB_CURRENT_VERSION = 2.0.0; FRAMEWORK_VERSION = A; HEADER_SEARCH_PATHS = mysqlclient_source/headers; *************** *** 452,458 **** <string>????</string> <key>CFBundleVersion</key> ! <string>0.7.0d1</string> <key>NSPrincipalClass</key> ! <string>SMySQLConnection</string> </dict> </plist> --- 453,459 ---- <string>????</string> <key>CFBundleVersion</key> ! <string>2.0.0d1</string> <key>NSPrincipalClass</key> ! <string>MCPConnection</string> </dict> </plist> *************** *** 1846,1851 **** ); buildSettings = { ! DYLIB_COMPATIBILITY_VERSION = 1.0.0; ! DYLIB_CURRENT_VERSION = 0.7.0; FRAMEWORK_VERSION = A; LIBRARY_SEARCH_PATHS = /usr/local/lib/mysql; --- 1847,1852 ---- ); buildSettings = { ! DYLIB_COMPATIBILITY_VERSION = 2.0.0; ! DYLIB_CURRENT_VERSION = 2.0.0; FRAMEWORK_VERSION = A; LIBRARY_SEARCH_PATHS = /usr/local/lib/mysql; *************** *** 1893,1899 **** <string>????</string> <key>CFBundleVersion</key> ! <string>0.7.0d1</string> <key>NSPrincipalClass</key> ! <string>SMySQLConnection</string> </dict> </plist> --- 1894,1900 ---- <string>????</string> <key>CFBundleVersion</key> ! <string>2.0.0d1</string> <key>NSPrincipalClass</key> ! <string>MCPConnection</string> </dict> </plist> *************** *** 2042,2046 **** ); shellPath = /bin/sh; ! shellScript = "MKDIRS=\"mkdir -p\"\nAUTODOC=/usr/local/bin/autodoc\nAUTODOC_FLAGS=\"-copydocs -timestamp -allclasses\"\nAUTODOC_FORMAT=html\nAUTODOC_LANGUAGE=English\nexport AD_COPYRIGHT=\"MySQL Cocoa Project\"\n\n# If autodoc is not installed, we quit without any error\ntest -x $AUTODOC || exit 0\n\nPUBLIC_DOC_INSTALLDIR=\"$SYMROOT/$PRODUCT_NAME.framework/Resources/$AUTODOC_LANGUAGE.lproj/Documentation\"\n\n# We need to write down file names here\nAUTODOC_FILES=\"SMySQLConnection.h SMySQLResult.h\"\nAUTODOC_DOCDIR=\"$PUBLIC_DOC_INSTALLDIR\"\n\nOTHER_AUTODOC_FLAGS=\"-typedirs -allclasses -combine -force -nosingles\"\n\nALL_AUTODOC_FLAGS=\"$AUTODOC_FLAGS $OTHER_AUTODOC_FLAGS\"\n\n$MKDIRS $PUBLIC_DOC_INSTALLDIR\n$AUTODOC $ALL_AUTODOC_FLAGS -format $AUTODOC_FORMAT -dest $AUTODOC_DOCDIR $AUTODOC_FILES\n"; }; F5C0D59002884F280172C088 = { --- 2043,2047 ---- ); shellPath = /bin/sh; ! shellScript = "MKDIRS=\"mkdir -p\"\nAUTODOC=/usr/local/bin/autodoc\nAUTODOC_FLAGS=\"-copydocs -timestamp -allclasses\"\nAUTODOC_FORMAT=html\nAUTODOC_LANGUAGE=English\nexport AD_COPYRIGHT=\"MySQL Cocoa Project\"\n\n# If autodoc is not installed, we quit without any error\ntest -x $AUTODOC || exit 0\n\nPUBLIC_DOC_INSTALLDIR=\"$SYMROOT/$PRODUCT_NAME.framework/Resources/$AUTODOC_LANGUAGE.lproj/Documentation\"\n\n# We need to write down file names here\nAUTODOC_FILES=\"MCPConnection.h MCPResult.h\"\nAUTODOC_DOCDIR=\"$PUBLIC_DOC_INSTALLDIR\"\n\nOTHER_AUTODOC_FLAGS=\"-typedirs -allclasses -combine -force -nosingles\"\n\nALL_AUTODOC_FLAGS=\"$AUTODOC_FLAGS $OTHER_AUTODOC_FLAGS\"\n\n$MKDIRS $PUBLIC_DOC_INSTALLDIR\n$AUTODOC $ALL_AUTODOC_FLAGS -format $AUTODOC_FORMAT -dest $AUTODOC_DOCDIR $AUTODOC_FILES\n"; }; F5C0D59002884F280172C088 = { *************** *** 2065,2069 **** ); shellPath = /bin/sh; ! shellScript = "MKDIRS=\"mkdir -p\"\nAUTODOC=/usr/local/bin/autodoc\nAUTODOC_FLAGS=\"-copydocs -timestamp -allclasses\"\nAUTODOC_FORMAT=html\nAUTODOC_LANGUAGE=English\nexport AD_COPYRIGHT=\"MySQL Cocoa Project\"\n\n# If autodoc is not installed, we quit without any error\ntest -x $AUTODOC || exit 0\n\nPUBLIC_DOC_INSTALLDIR=\"$SYMROOT/$PRODUCT_NAME.framework/Resources/$AUTODOC_LANGUAGE.lproj/Documentation\"\n\n# We need to write down file names here\nAUTODOC_FILES=\"SMySQLConnection.h SMySQLResult.h\"\nAUTODOC_DOCDIR=\"$PUBLIC_DOC_INSTALLDIR\"\n\nOTHER_AUTODOC_FLAGS=\"-typedirs -allclasses -combine -force -nosingles\"\n\nALL_AUTODOC_FLAGS=\"$AUTODOC_FLAGS $OTHER_AUTODOC_FLAGS\"\n\n$MKDIRS $PUBLIC_DOC_INSTALLDIR\n$AUTODOC $ALL_AUTODOC_FLAGS -format $AUTODOC_FORMAT -dest $AUTODOC_DOCDIR $AUTODOC_FILES\n"; }; }; --- 2066,2089 ---- ); shellPath = /bin/sh; ! shellScript = "MKDIRS=\"mkdir -p\"\nAUTODOC=/usr/local/bin/autodoc\nAUTODOC_FLAGS=\"-copydocs -timestamp -allclasses\"\nAUTODOC_FORMAT=html\nAUTODOC_LANGUAGE=English\nexport AD_COPYRIGHT=\"MySQL Cocoa Project\"\n\n# If autodoc is not installed, we quit without any error\ntest -x $AUTODOC || exit 0\n\nPUBLIC_DOC_INSTALLDIR=\"$SYMROOT/$PRODUCT_NAME.framework/Resources/$AUTODOC_LANGUAGE.lproj/Documentation\"\n\n# We need to write down file names here\nAUTODOC_FILES=\"MCPConnection.h MCPResult.h\"\nAUTODOC_DOCDIR=\"$PUBLIC_DOC_INSTALLDIR\"\n\nOTHER_AUTODOC_FLAGS=\"-typedirs -allclasses -combine -force -nosingles\"\n\nALL_AUTODOC_FLAGS=\"$AUTODOC_FLAGS $OTHER_AUTODOC_FLAGS\"\n\n$MKDIRS $PUBLIC_DOC_INSTALLDIR\n$AUTODOC $ALL_AUTODOC_FLAGS -format $AUTODOC_FORMAT -dest $AUTODOC_DOCDIR $AUTODOC_FILES\n"; ! }; ! F5F6CECD02A6946E015D9B03 = { ! children = ( ! F5F6CECE02A69498015D9B03, ! F5F6CECF02A694C1015D9B03, ! ); ! isa = PBXGroup; ! name = "TO DO, etc"; ! refType = 4; ! }; ! F5F6CECE02A69498015D9B03 = { ! isa = PBXFileReference; ! path = README; ! refType = 2; ! }; ! F5F6CECF02A694C1015D9B03 = { ! isa = PBXFileReference; ! path = TO_DO; ! refType = 4; }; }; Index: cohen.pbxuser =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQL.pbproj/cohen.pbxuser,v retrieving revision 1.13 retrieving revision 1.13.2.1 diff -C2 -d -r1.13 -r1.13.2.1 *** cohen.pbxuser 15 May 2002 11:10:02 -0000 1.13 --- cohen.pbxuser 1 Jun 2002 20:59:00 -0000 1.13.2.1 *************** *** 5,9 **** activeTarget = F51A62D7022D7C2A01952E7A; addToTargets = ( - F51A62D7022D7C2A01952E7A, ); breakpoints = ( --- 5,8 ---- *************** *** 16,23 **** Frame = "{{0, 23}, {971, 624}}"; Split0 = { ! ActiveTab = 2; ! Frame = "{{186, 0}, {785, 624}}"; Split0 = { ! Frame = "{{0, 216}, {785, 408}}"; }; SplitCount = 1; --- 15,21 ---- Frame = "{{0, 23}, {971, 624}}"; Split0 = { ! Frame = "{{232, 0}, {739, 624}}"; Split0 = { ! Frame = "{{0, 24}, {739, 600}}"; }; SplitCount = 1; *************** *** 55,64 **** }; Tab2 = { ! BuildMessageFrame = "{{0, 0}, {787, 95}}"; ! BuildTranscriptFrame = "{{0, 104}, {787, 90}}"; ! Frame = "{{0, 0}, {785, 192}}"; }; Tab3 = { ! Frame = "{{0, 0}, {747, 295}}"; }; TabCount = 4; --- 53,62 ---- }; Tab2 = { ! BuildMessageFrame = "{{0, 0}, {741, 95}}"; ! BuildTranscriptFrame = "{{0, 104}, {741, 90}}"; ! Frame = "{{0, 0}, {739, 192}}"; }; Tab3 = { ! Frame = "{{0, 0}, {739, 295}}"; }; TabCount = 4; *************** *** 66,70 **** SplitCount = 1; Tab0 = { ! Frame = "{{0, 0}, {162, 624}}"; }; Tab1 = { --- 64,68 ---- SplitCount = 1; Tab0 = { ! Frame = "{{0, 0}, {208, 624}}"; }; Tab1 = { *************** *** 92,95 **** --- 90,94 ---- TabCount = 5; }; + WindowLocation = "{34, 32}"; }; }; |
Update of /cvsroot/mysql-cocoa/SMySQL In directory usw-pr-cvs1:/tmp/cvs-serv2036 Modified Files: Tag: version-2 README SMySQL.h MCPConnection.h MCPConnection.m MCPResult.h MCPResult.m Added Files: Tag: version-2 TO_DO Log Message: Modified classes to be: MCPConnection MCPResult Added a TO_DO, updated the README file (fom within the project). Serge Cohen; MySQL Cocoa project, 2002-06-01. --- NEW FILE: TO_DO --- TO DO list for this version of SMySQL (version 2): ++Handling NULL fields: - Create a MCPNull object to reflect NULL columns values in retrieved table rows. - Create a "MCPNull" category for NSObject with only one method : isMCPNull (Being able to check if any object returned by SMySQL is a MCPNull) ++MCPResult: Centralising the field type recognition and filling of proper objects: - A single method doing the work : fetchRowAsType:(unsigned int) aType; - Wrapper for getting rows as Dictionnary or Array. Making a category for additional (optional) methods: - Getting a single column: - (NSArray *) fetchColWithIndex:(unsigned int) aCol; - (NSArray *) fetchColWithName:(NSString *) aColName; (Wrapping the previous one) - Adding bidimensional array data retrieval (in a Category?) ++MCPConnection Making a category to add some useful (but not mandatory) features: - (id) getFirstFieldFromQuery:(NSString *) query; (Frist column of first row of the result) - (id) getFirstRowFromQuery:(NSString *) query asType:(unsigned int) aType; (obvious) - (NSArray *) getAllRowsFromQuery:(NSString *) queryasType:(unsigned int) aType; (using 2D possibility of MCPResult) - (NSArray *) getQuery:(NSString *) query colWithIndex:(unsigned int) aCol; (Getting a single column form the query) - (NSArray *) getQuery:(NSString *) query colWithName:(NSString *) aColName; Index: README =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/README,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** README 1 Jan 2002 17:16:29 -0000 1.1.1.1 --- README 1 Jun 2002 20:58:18 -0000 1.1.1.1.2.1 *************** *** 1,18 **** READ ME file for SMySQL, from MySQL Cocoa project. - To install this framework, you need a properly compiled libmysqlclient.dylib. - To find instruction on how to compile mysql on Mac OSX 10.1.x, go to the Documentation package from the site. - You need also to have the headers coming with libmysqlclient: ! mysql.h ! mysql_com.h ! mysql_version.h ! These headers should be in : /usr/local/include/mysql/ ! The library should be in : /usr/local/lib/mysql/ ! Otherwise you will have to change some settings in the target, so that the compiler and linker can find the proper files. ! Serge Cohen, 30 December 2001. --- 1,82 ---- READ ME file for SMySQL, from MySQL Cocoa project. ! ++++++++++++++++++++++++++++++++ ! + Aim of this Framework: ! ++++++++++++++++++++++++++++++++ ! This framework is aimed at programers which want to connect to a MySQL database from a application developed with Cocoa (and maybe GNUStep, although I've not tried myself). The framework is based on the C API of MySQL and hence uses (or include) the libmysqlclient library coming from MySQL. ! Objects from this framework (namely MCPConnection and MCPResult) belongs to the Model layer and uses anly the Foundation API. The development is done with Project Builder (the IDE from Apple -previously NeXT-), and no other environment is supported (yet !! if you want ot port it to another env. I'll be glad to provide you with all the information I know which can help you). ! ! ++++++++++++++++++++++++++++++++ ! + Flavours: ! ++++++++++++++++++++++++++++++++ ! ! The SMySQL framework comes in 3 flavours, that's because: ! 1. Frameworks can have different policies to be installed on a system and used by an App. ! 2. The framework relies on the code from the libmysqlclient library to work. ! ! Let's first adress these two points, and then the description of the flavoured should much clearer. ! ! 1. Frameworks location (Indeed I would suggest you read Apple doc about OS X...): ! If a framework is used by many applications, it's better to have a central repository for him. This repository exist, it's the folder Library/Frameworks (of any of the domains: System, Network, User ...). Any application which need one of these framework just declare the of the framework, and the dynamic linker will look for it in all these repository (in a given order which you'll find in Apple doc). ! -> Lets call this kind of framework a 'Global framework' ! ! In the mean time, an application programmer might want to wrap some of his application capabilities in a framework (to be able to use it in another app easily). In this case it's better if the framework does not take place (and namespace) in the central repository, even more it's better if you don't have to ask the user to install a framework to be able to run the app. In this aim you can embed the framework in the application bundle (in the "Contents/Frameworks/" folder of the bundle). Then you should set precisely the path to reach the framework (at compile time). ! -> Lets call this kind of framework a 'embeded framework' ! ! ! 2. The form libmysqlclient used: ! The same kind question arise about libmysqlclient, it exists in two forms: static library (archive), or dynamic lib (shared object). ! The dynamic lib is much better to use if the user had it setted personnaly (give coherence to all the applications using the client side of mysql) BUT it might forces the user to install one more thing. ! ! In the case the application might be installed by users who doe not to bother with mysql installation, it's much easier for the user to have the library staticly linked (one once for all by the developer) in the framework. ! ! ! -- Now the 3 flavours of the framework: ! 1. Target : SMySQL ! The framework is to be installed in one of the central repository. And because you're not afraid of this knid of installs, this one relies on the dynamic version of libmysqlclient. One of the big PLUS of this install is that you can use the framework even in "Foundation" type application (command line interface, launched in terminal). ! ! 2. Target : SMySQL_embeded ! Kind of a mix target (exists mainly for historic reasons). The framework is made to be embeded in the application (and not clutter the central repositories), but it relies on the dynamic verison of the library (interesting if you have to install this lib for other API, like PERL's). ! ! 3. Target : SMySQL_fully_embeded ! The framework is made to be embeded in the application bundle and DOES NOT rely on any external libraries (except the one provided as standard with Mac OS X). In this target the libmysqlclient is staticly linked in the framework. ! ! NB: Only 1. can be used from a "Foundation" application (like SMySQL_test). For GUI application the method recommended is 3. (from Apple recommandation). ! ! ! ++++++++++++++++++++++++++++++++ ! + Installation: ! ++++++++++++++++++++++++++++++++ ! ! If you want to install flavours 1 or 2 (targets SMySQL or SMySQL_embeded), you have to have a working version of libmysqlclient together with the corresponding header files. You can get some infos on how to install the libmysqlclient lib in the Documentation package from the web site (mysql-cocoa.sf.net). ! ! For flavour 1: ! in Terminal (after installation of libmysqlclient), cd to the source directory and issue the two commands: ! >cd SMySQL.pbproj ! >pbxbuild -target SMySQL -buildstyle Development install DSTROOT=/ ! ! For flavour 2: ! Once the client side of MySQL is installed, you just have to open the project in Project Builder, select the target (SMySQL_embeded), the buildstyle and click the Build button. ! ! For flavour 3: ! Just get the project in PB, select target (SMySQL_fully_embeded), build style, and press Build. ! ! In all the three case the html doc is generated if you have AutoDoc (http://www.misckit.com/press/press_autodoc_2.0b7.html) installed. It will be in the directory: ! SMySQL.framework/Resources/English.lproj/Documentation/ ! ! ! ++++++++++++++++++++++++++++++++ ! + Use: ! ++++++++++++++++++++++++++++++++ ! ! ! Still to come.... ! ! ! Serge Cohen; MySQL Cocoa project, 2002-01-06. Index: SMySQL.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQL.h,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** SMySQL.h 7 May 2002 18:43:58 -0000 1.2 --- SMySQL.h 1 Jun 2002 20:58:18 -0000 1.2.2.1 *************** *** 25,30 **** #import <Foundation/Foundation.h> ! #import <SMySQL/SMySQLResult.h> ! #import <SMySQL/SMySQLConnection.h> #import "mysql.h" //#import <SMySQL/mysql.h> --- 25,30 ---- #import <Foundation/Foundation.h> ! #import <SMySQL/MCPResult.h> ! #import <SMySQL/MCPConnection.h> #import "mysql.h" //#import <SMySQL/mysql.h> Index: MCPConnection.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPConnection.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** MCPConnection.h 30 May 2002 13:52:01 -0000 1.1.2.1 --- MCPConnection.h 1 Jun 2002 20:58:18 -0000 1.1.2.2 *************** *** 1,4 **** // ! // SMySQLConnection.h // SMySQL // --- 1,4 ---- // ! // MCPConnection.h // SMySQL // *************** *** 29,39 **** //#import <SMySQL/SMySQL.h> ! @class SMySQLResult; ! #define kSMySQL_default_option CLIENT_COMPRESS ! #define kSMySQLConnectionDefaultSocket MYSQL_UNIX_ADDR ! #define kSMySQLConnection_error_not_inited 1000 ! @interface SMySQLConnection : NSObject { MYSQL *mConnection; /*"The inited MySQL connection"*/ BOOL mConnected; /*"Reflect the fact that the connection is already in place or not"*/ --- 29,44 ---- //#import <SMySQL/SMySQL.h> ! @class MCPResult; ! // Deafult connection option ! extern const unsigned int kMCPConnectionDefaultOption; ! // Default socket (from the mysql.h used at compile time) ! extern NSString *kMCPConnectionDefaultSocket; ! ! // Added to mysql error code ! extern const unsigned int kMCPConnectionNotInited; ! ! @interface MCPConnection : NSObject { MYSQL *mConnection; /*"The inited MySQL connection"*/ BOOL mConnected; /*"Reflect the fact that the connection is already in place or not"*/ *************** *** 77,81 **** - (NSString *) prepareString:(NSString *) theString; ! - (SMySQLResult *) queryString:(NSString *) query; - (my_ulonglong) affectedRows; --- 82,86 ---- - (NSString *) prepareString:(NSString *) theString; ! - (MCPResult *) queryString:(NSString *) query; - (my_ulonglong) affectedRows; *************** *** 86,97 **** Getting description of the database structure "*/ ! - (SMySQLResult *) listDBs; ! - (SMySQLResult *) listDBsLike:(NSString *) dbsName; ! - (SMySQLResult *) listTables; ! - (SMySQLResult *) listTablesLike:(NSString *) tablesName; // Next method uses SHOW TABLES FROM db to be sure that the db is not changed during this call. ! - (SMySQLResult *) listTablesFromDB:(NSString *) dbName like:(NSString *) tablesName; ! - (SMySQLResult *) listFieldsFromTable:(NSString *) tableName; ! - (SMySQLResult *) listFieldsFromTable:(NSString *) tableName like:(NSString *) fieldsName; --- 91,102 ---- Getting description of the database structure "*/ ! - (MCPResult *) listDBs; ! - (MCPResult *) listDBsLike:(NSString *) dbsName; ! - (MCPResult *) listTables; ! - (MCPResult *) listTablesLike:(NSString *) tablesName; // Next method uses SHOW TABLES FROM db to be sure that the db is not changed during this call. ! - (MCPResult *) listTablesFromDB:(NSString *) dbName like:(NSString *) tablesName; ! - (MCPResult *) listFieldsFromTable:(NSString *) tableName; ! - (MCPResult *) listFieldsFromTable:(NSString *) tableName like:(NSString *) fieldsName; *************** *** 104,108 **** - (NSString *) serverInfo; - (NSNumber *) protoInfo; ! - (SMySQLResult *) listProcesses; - (BOOL) killProcess:(unsigned long) pid; --- 109,113 ---- - (NSString *) serverInfo; - (NSNumber *) protoInfo; ! - (MCPResult *) listProcesses; - (BOOL) killProcess:(unsigned long) pid; Index: MCPConnection.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPConnection.m,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** MCPConnection.m 30 May 2002 13:41:47 -0000 1.1.2.1 --- MCPConnection.m 1 Jun 2002 20:58:18 -0000 1.1.2.2 *************** *** 1,4 **** // ! // SMySQLConnection.m // SMySQL // --- 1,4 ---- // ! // MCPConnection.m // SMySQL // *************** *** 24,42 **** ! #import "SMySQLConnection.h" ! #import "SMySQLResult.h" ! @implementation SMySQLConnection /*" This class is used to keep a connection with a MySQL server, it correspond to the MYSQL structure of the C API, or the database handle of the PERL DBI/DBD interface. ! You have to start any work on a MySQL server by getting a working SMySQLConnection object. Most likely you will use this kind of code: !{ ! SMySQLConnection *theConnec = [SMySQLConnection alloc]; ! SMySQLResult *theRes; theConnec = [theConnec initToHost::albert.com withLogin:@"toto" password:@"albert" port:0]; --- 24,46 ---- ! #import "MCPConnection.h" ! #import "MCPResult.h" + const unsigned int kMCPConnectionDefaultOption = CLIENT_COMPRESS; + NSString *kMCPConnectionDefaultSocket = MYSQL_UNIX_ADDR; + const unsigned int kMCPConnection_Not_Inited = 1000; ! ! @implementation MCPConnection /*" This class is used to keep a connection with a MySQL server, it correspond to the MYSQL structure of the C API, or the database handle of the PERL DBI/DBD interface. ! You have to start any work on a MySQL server by getting a working MCPConnection object. Most likely you will use this kind of code: !{ ! MCPConnection *theConnec = [MCPConnection alloc]; ! MCPResult *theRes; theConnec = [theConnec initToHost::albert.com withLogin:@"toto" password:@"albert" port:0]; *************** *** 100,104 **** "*/ { ! return [SMySQLConnection encodingForMySQLEncoding:MYSQL_CHARSET]; } --- 104,108 ---- "*/ { ! return [MCPConnection encodingForMySQLEncoding:MYSQL_CHARSET]; } *************** *** 117,121 **** } // mEncoding = NSISOLatin1StringEncoding; ! mEncoding = [SMySQLConnection encodingForMySQLEncoding:mysql_character_set_name(mConnection)]; return self; } --- 121,125 ---- } // mEncoding = NSISOLatin1StringEncoding; ! mEncoding = [MCPConnection encodingForMySQLEncoding:mysql_character_set_name(mConnection)]; return self; } *************** *** 193,200 **** #{NOT YET IMPLEMENTED} ! This method is to be used for getting special option for a connection, in which case the SMySQLConnection has to be inited with the init method, then option are selected, finally connection is done using one of the connect methods: !{ ! SMySQLConnection *theConnect = [[SMySQLConnection alloc] init]; [theConnect setConnectionOption: option withArgument: arg]; [theConnect connectToHost:albert.com withLogin:@"toto" password:@"albert" port:0]; --- 197,204 ---- #{NOT YET IMPLEMENTED} ! This method is to be used for getting special option for a connection, in which case the MCPConnection has to be inited with the init method, then option are selected, finally connection is done using one of the connect methods: !{ ! MCPConnection *theConnect = [[MCPConnection alloc] init]; [theConnect setConnectionOption: option withArgument: arg]; [theConnect connectToHost:albert.com withLogin:@"toto" password:@"albert" port:0]; *************** *** 246,257 **** } if (theSocket == NULL) { ! theSocket = kSMySQLConnectionDefaultSocket; } ! theRet = mysql_real_connect(mConnection, theHost, theLogin, thePass, NULL, port, theSocket, kSMySQL_default_option); if (theRet != mConnection) { return mConnected = NO; } ! mEncoding = [SMySQLConnection encodingForMySQLEncoding:mysql_character_set_name(mConnection)]; return mConnected = YES; } --- 250,261 ---- } if (theSocket == NULL) { ! theSocket = kMCPConnectionDefaultSocket; } ! theRet = mysql_real_connect(mConnection, theHost, theLogin, thePass, NULL, port, theSocket, kMCPConnectionDefaultOption); if (theRet != mConnection) { return mConnected = NO; } ! mEncoding = [MCPConnection encodingForMySQLEncoding:mysql_character_set_name(mConnection)]; return mConnected = YES; } *************** *** 261,265 **** /*" Selects a database to work with. ! The SMySQLConnection object needs to be properly inited and connected to a server. If a connection is not yet set or the selection of the database didn't work, returns NO. Returns YES in normal cases where the database is properly selected. --- 265,269 ---- /*" Selects a database to work with. ! The MCPConnection object needs to be properly inited and connected to a server. If a connection is not yet set or the selection of the database didn't work, returns NO. Returns YES in normal cases where the database is properly selected. *************** *** 303,312 **** return mysql_errno(mConnection); } ! return kSMySQLConnection_error_not_inited; } - (BOOL) isConnected /*" ! Returns YES if the SMySQLConnection is connected to a DB, NO otherwise. "*/ { --- 307,316 ---- return mysql_errno(mConnection); } ! return kMCPConnection_Not_Inited; } - (BOOL) isConnected /*" ! Returns YES if the MCPConnection is connected to a DB, NO otherwise. "*/ { *************** *** 359,370 **** ! - (SMySQLResult *) queryString:(NSString *) query /*" ! Takes a query string and return an SMySQLResult object holding the result of the query. ! The returned SMySQLResult is not retained, the client is responsible for that (it's autoreleased before being returned) Note that if you want to use this method with binary data (in the query), you should use !{prepareBinaryData:} to include the binary data in the query string. "*/ { ! SMySQLResult *theResult = [SMySQLResult alloc]; const char *theCQuery = [self cStringFromString:query]; int theQueryCode; --- 363,374 ---- ! - (MCPResult *) queryString:(NSString *) query /*" ! Takes a query string and return an MCPResult object holding the result of the query. ! The returned MCPResult is not retained, the client is responsible for that (it's autoreleased before being returned) Note that if you want to use this method with binary data (in the query), you should use !{prepareBinaryData:} to include the binary data in the query string. "*/ { ! MCPResult *theResult = [MCPResult alloc]; const char *theCQuery = [self cStringFromString:query]; int theQueryCode; *************** *** 413,417 **** ! - (SMySQLResult *) listDBs /*" Just a fast wrapper for the more complex !{listDBsWithPattern:} method. --- 417,421 ---- ! - (MCPResult *) listDBs /*" Just a fast wrapper for the more complex !{listDBsWithPattern:} method. *************** *** 422,426 **** ! - (SMySQLResult *) listDBsLike:(NSString *) dbsName /*" Returns a list of database which name correspond to the SQL regular expression in 'pattern'. --- 426,430 ---- ! - (MCPResult *) listDBsLike:(NSString *) dbsName /*" Returns a list of database which name correspond to the SQL regular expression in 'pattern'. *************** *** 430,434 **** "*/ { ! SMySQLResult *theResult = [SMySQLResult alloc]; MYSQL_RES *theResPtr; --- 434,438 ---- "*/ { ! MCPResult *theResult = [MCPResult alloc]; MYSQL_RES *theResPtr; *************** *** 457,461 **** ! - (SMySQLResult *) listTables /*" Make sure a DB is selected (with !{selectDB} method) first. --- 461,465 ---- ! - (MCPResult *) listTables /*" Make sure a DB is selected (with !{selectDB} method) first. *************** *** 466,470 **** ! - (SMySQLResult *) listTablesLike:(NSString *) tablesName /*" From within a database, give back the list of table which name correspond to tablesName (with wild card %, _ extension). Correspond to queryString:@"SHOW tables [LIKE wild]"; uses mysql_list_tables function. --- 470,474 ---- ! - (MCPResult *) listTablesLike:(NSString *) tablesName /*" From within a database, give back the list of table which name correspond to tablesName (with wild card %, _ extension). Correspond to queryString:@"SHOW tables [LIKE wild]"; uses mysql_list_tables function. *************** *** 473,477 **** "*/ { ! SMySQLResult *theResult = [SMySQLResult alloc]; MYSQL_RES *theResPtr; --- 477,481 ---- "*/ { ! MCPResult *theResult = [MCPResult alloc]; MYSQL_RES *theResPtr; *************** *** 500,504 **** ! - (SMySQLResult *) listTablesFromDB:(NSString *) dbName like:(NSString *) tablesName /*" List tables in DB specified by dbName and corresponding to pattern. --- 504,508 ---- ! - (MCPResult *) listTablesFromDB:(NSString *) dbName like:(NSString *) tablesName /*" List tables in DB specified by dbName and corresponding to pattern. *************** *** 507,511 **** "*/ { ! SMySQLResult *theResult; if ((tablesName == nil) || ([tablesName isEqualToString:@""])) { --- 511,515 ---- "*/ { ! MCPResult *theResult; if ((tablesName == nil) || ([tablesName isEqualToString:@""])) { *************** *** 521,525 **** ! - (SMySQLResult *)listFieldsFromTable:(NSString *)tableName /*" Just a fast wrapper for the more complex list !{listFieldsWithPattern:forTable:} method. --- 525,529 ---- ! - (MCPResult *)listFieldsFromTable:(NSString *)tableName /*" Just a fast wrapper for the more complex list !{listFieldsWithPattern:forTable:} method. *************** *** 530,534 **** ! - (SMySQLResult *) listFieldsFromTable:(NSString *) tableName like:(NSString *) fieldsName /*" Show all the fields of the table tableName which name correspond to pattern (with wild card expansion : %,_). --- 534,538 ---- ! - (MCPResult *) listFieldsFromTable:(NSString *) tableName like:(NSString *) fieldsName /*" Show all the fields of the table tableName which name correspond to pattern (with wild card expansion : %,_). *************** *** 537,541 **** "*/ { ! SMySQLResult *theResult; if ((fieldsName == nil) || ([fieldsName isEqualToString:@""])) { --- 541,545 ---- "*/ { ! MCPResult *theResult; if ((fieldsName == nil) || ([fieldsName isEqualToString:@""])) { *************** *** 590,599 **** ! - (SMySQLResult *) listProcesses /*" Lists active process "*/ { ! SMySQLResult *theResult = [SMySQLResult alloc]; MYSQL_RES *theResPtr; --- 594,603 ---- ! - (MCPResult *) listProcesses /*" Lists active process "*/ { ! MCPResult *theResult = [MCPResult alloc]; MYSQL_RES *theResPtr; *************** *** 647,651 **** - (void) disconnect /*" ! Disconnects a connected SMySQLConnection object; used by #{-dealloc} method. "*/ { --- 651,655 ---- - (void) disconnect /*" ! Disconnects a connected MCPConnection object; used by #{-dealloc} method. "*/ { *************** *** 660,664 **** - (void)dealloc /*" ! The standard deallocation method for SMySQLConnection objects. "*/ { --- 664,668 ---- - (void)dealloc /*" ! The standard deallocation method for MCPConnection objects. "*/ { *************** *** 673,677 **** Sets the encoding used by the server for data transfert. Used to make sure the output of the query result is ok even for non-ascii characters ! The character set (encoding) used by the db is passed to the SMySQLConnection object upon connection, so most likely the encoding (from -encoding) method is already the proper one. That is to say : It's unlikely you will need to call this method directly, and #{if ever you use it, do it at your own risks}. --- 677,681 ---- Sets the encoding used by the server for data transfert. Used to make sure the output of the query result is ok even for non-ascii characters ! The character set (encoding) used by the db is passed to the MCPConnection object upon connection, so most likely the encoding (from -encoding) method is already the proper one. That is to say : It's unlikely you will need to call this method directly, and #{if ever you use it, do it at your own risks}. *************** *** 693,697 **** - (const char *) cStringFromString:(NSString *) theString /*" ! For internal use only. Transforms a NSString to a C type string (ending with \0) using the character set from the SMySQLConnection. Lossy conversions are enabled. "*/ --- 697,701 ---- - (const char *) cStringFromString:(NSString *) theString /*" ! For internal use only. Transforms a NSString to a C type string (ending with \0) using the character set from the MCPConnection. Lossy conversions are enabled. "*/ *************** *** 711,715 **** - (NSString *) stringWithCString:(const char *) theCString /*" ! Returns a NSString from a C style string encoded with the character set of theSMySQLConnection. "*/ { --- 715,719 ---- - (NSString *) stringWithCString:(const char *) theCString /*" ! Returns a NSString from a C style string encoded with the character set of theMCPConnection. "*/ { Index: MCPResult.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPResult.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** MCPResult.h 30 May 2002 13:52:01 -0000 1.1.2.1 --- MCPResult.h 1 Jun 2002 20:58:18 -0000 1.1.2.2 *************** *** 1,4 **** // ! // SMySQLResult.h // SMySQL // --- 1,4 ---- // ! // MCPResult.h // SMySQL // *************** *** 29,35 **** //#import <SMySQL/SMySQL.h> ! //@class SMySQLRow; ! ! @interface SMySQLResult : NSObject { MYSQL_RES *mResult; /*"The MYSQL_RES structure of the C API"*/ NSArray *mNames; /*"An NSArray holding the name of the columns"*/ --- 29,33 ---- //#import <SMySQL/SMySQL.h> ! @interface MCPResult : NSObject { MYSQL_RES *mResult; /*"The MYSQL_RES structure of the C API"*/ NSArray *mNames; /*"An NSArray holding the name of the columns"*/ *************** *** 39,43 **** /*" ! Init used #{only} by #{SMySQLConnection} "*/ --- 37,41 ---- /*" ! Init used #{only} by #{MCPConnection} "*/ Index: MCPResult.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/Attic/MCPResult.m,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** MCPResult.m 30 May 2002 13:52:01 -0000 1.1.2.1 --- MCPResult.m 1 Jun 2002 20:58:18 -0000 1.1.2.2 *************** *** 1,4 **** // ! // SMySQLResult.m // SMySQL // --- 1,4 ---- // ! // MCPResult.m // SMySQL // *************** *** 24,33 **** ! #import "SMySQLConnection.h" ! #import "SMySQLResult.h" ! @implementation SMySQLResult /*" Hold the results of a query to a MySQL database server. It correspond to the MYSQL_RES structure of the C API, and to the statement handle of the PERL DBI/DBD. --- 24,33 ---- ! #import "MCPConnection.h" ! #import "MCPResult.h" ! @implementation MCPResult /*" Hold the results of a query to a MySQL database server. It correspond to the MYSQL_RES structure of the C API, and to the statement handle of the PERL DBI/DBD. *************** *** 35,43 **** Uses the #{mysql_store_result()} function from the C API. ! This object is generated only by a SMySQLConnection object, in this way (see #{SMySQLConnection} documentation): !{ ! SMySQLConnection *theConnec = [SMySQLConnection alloc]; ! SMySQLResult *theRes; NSDictionnary *theDict; NSArray *theColNames; --- 35,43 ---- Uses the #{mysql_store_result()} function from the C API. ! This object is generated only by a MCPConnection object, in this way (see #{MCPConnection} documentation): !{ ! MCPConnection *theConnec = [MCPConnection alloc]; ! MCPResult *theRes; NSDictionnary *theDict; NSArray *theColNames; *************** *** 62,66 **** - (id)initWithMySQLPtr:(MYSQL *)mySQLPtr encoding:(NSStringEncoding)theEncoding /*" ! initialise a SMySQLResult, it is used internally by SMySQLConnection #{queryString:} method: the only proper way to get a running SMySQLResult object. "*/ { --- 62,66 ---- - (id)initWithMySQLPtr:(MYSQL *)mySQLPtr encoding:(NSStringEncoding)theEncoding /*" ! initialise a MCPResult, it is used internally by MCPConnection #{queryString:} method: the only proper way to get a running MCPResult object. "*/ { *************** *** 83,87 **** */ if (mMySQLLocales == NULL) { ! mMySQLLocales = [[SMySQLConnection getMySQLLocales] retain]; } return self; --- 83,87 ---- */ if (mMySQLLocales == NULL) { ! mMySQLLocales = [[MCPConnection getMySQLLocales] retain]; } return self; *************** *** 91,97 **** - (id)initWithResPtr:(MYSQL_RES *)mySQLResPtr encoding:(NSStringEncoding)theEncoding /*" ! This metod it is used internally by SMySQLConnection object when it have already a MYSQL_RES object to initialise SMySQLResult object. ! Initialise a SMySQLResult with the MYSQL_RES pointer (returned by such a function as mysql_list_dbs). ! NB: SMySQLResult should be made by using one of the method of SMySQLConnection. "*/ { --- 91,97 ---- - (id)initWithResPtr:(MYSQL_RES *)mySQLResPtr encoding:(NSStringEncoding)theEncoding /*" ! This metod it is used internally by MCPConnection object when it have already a MYSQL_RES object to initialise MCPResult object. ! Initialise a MCPResult with the MYSQL_RES pointer (returned by such a function as mysql_list_dbs). ! NB: MCPResult should be made by using one of the method of MCPConnection. "*/ { *************** *** 114,118 **** */ if (mMySQLLocales == NULL) { ! mMySQLLocales = [[SMySQLConnection getMySQLLocales] retain]; } return self; --- 114,118 ---- */ if (mMySQLLocales == NULL) { ! mMySQLLocales = [[MCPConnection getMySQLLocales] retain]; } return self; *************** *** 121,129 **** - (id)init /*" ! Empty init, normaly of NO use to the user, again, SMySQLResult should be made through calls to SMySQLConnection "*/ { self = [super init]; ! mEncoding = [SMySQLConnection defaultMySQLEncoding]; if (mResult) { mysql_free_result(mResult); --- 121,129 ---- - (id)init /*" ! Empty init, normaly of NO use to the user, again, MCPResult should be made through calls to MCPConnection "*/ { self = [super init]; ! mEncoding = [MCPConnection defaultMySQLEncoding]; if (mResult) { mysql_free_result(mResult); *************** *** 135,139 **** } if (mMySQLLocales == NULL) { ! mMySQLLocales = [[SMySQLConnection getMySQLLocales] retain]; } return self; --- 135,139 ---- } if (mMySQLLocales == NULL) { ! mMySQLLocales = [[MCPConnection getMySQLLocales] retain]; } return self; *************** *** 532,536 **** default: theType = @"unknown"; ! NSLog (@"in fetchTypesAsArray : Unknown type for column %d of the SMySQLResult, type = %d", (int)i, (int)theField[i].type); break; } --- 532,536 ---- default: theType = @"unknown"; ! NSLog (@"in fetchTypesAsArray : Unknown type for column %d of the MCPResult, type = %d", (int)i, (int)theField[i].type); break; } *************** *** 638,642 **** default: theType = @"unknown"; ! NSLog (@"in fetchTypesAsDictionary : Unknown type for column %d of the SMySQLResult, type = %d", (int)i, (int)theField[i].type); break; } --- 638,642 ---- default: theType = @"unknown"; ! NSLog (@"in fetchTypesAsDictionary : Unknown type for column %d of the MCPResult, type = %d", (int)i, (int)theField[i].type); break; } *************** *** 730,738 **** - (NSString *)description /*" ! Return a (long) string containing the table of results, first line being the fields name, next line(s) the row(s). Useful to have NSLog logging a SMySQLResult (example). "*/ { if (mResult == NULL) { ! return @"This is an empty SMySQLResult\n"; } else { --- 730,738 ---- - (NSString *)description /*" ! Return a (long) string containing the table of results, first line being the fields name, next line(s) the row(s). Useful to have NSLog logging a MCPResult (example). "*/ { if (mResult == NULL) { ! return @"This is an empty MCPResult\n"; } else { *************** *** 742,747 **** MYSQL_ROW_OFFSET thePosition; ! // First line, saying we are displaying a SMySQLResult ! [theString appendString:@"SMySQLResult:\n"]; // Second line: the field names, tab separated [self fetchFieldsName]; --- 742,747 ---- MYSQL_ROW_OFFSET thePosition; ! // First line, saying we are displaying a MCPResult ! [theString appendString:@"MCPResult:\n"]; // Second line: the field names, tab separated [self fetchFieldsName]; *************** *** 787,791 **** - (const char *)cStringFromString:(NSString *)theString /*" ! For internal use only. Transform a NSString to a C type string (ended with \0) using ethe character set from the SMySQLConnection. Lossy conversions are enabled. "*/ --- 787,791 ---- - (const char *)cStringFromString:(NSString *)theString /*" ! For internal use only. Transform a NSString to a C type string (ended with \0) using ethe character set from the MCPConnection. Lossy conversions are enabled. "*/ *************** *** 805,809 **** - (NSString *)stringWithCString:(const char *)theCString /*" ! Return a NSString from a C style string encoded with the character set of theSMySQLConnection. "*/ { --- 805,809 ---- - (NSString *)stringWithCString:(const char *)theCString /*" ! Return a NSString from a C style string encoded with the character set of theMCPConnection. "*/ { |
From: Serge C. <ser...@us...> - 2002-06-01 20:58:21
|
Update of /cvsroot/mysql-cocoa/SMySQL/English.lproj In directory usw-pr-cvs1:/tmp/cvs-serv2098 Modified Files: Tag: version-2 InfoPlist.strings Log Message: Modified classes to be: MCPConnection MCPResult Added a TO_DO, updated the README file (fom within the project). Serge Cohen; MySQL Cocoa project, 2002-06-01. Index: InfoPlist.strings =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/English.lproj/InfoPlist.strings,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 Binary files /tmp/cvsdTUNhf and /tmp/cvsg6CMgk differ |
From: Serge C. <ser...@us...> - 2002-05-30 13:52:05
|
Update of /cvsroot/mysql-cocoa/SMySQL In directory usw-pr-cvs1:/tmp/cvs-serv13517 Added Files: Tag: version-2 MCPConnection.h MCPResult.h MCPResult.m Removed Files: Tag: version-2 SMySQLConnection.h SMySQLResult.h SMySQLResult.m Log Message: Reananed SMySQLConnection.h, SMySQLResult.h, SMySQLResult.m to respectivly MCPConnection.h, MCPResult.h, MCPResult.m. The new first letters for the framework class will be MCP (MySQL Cocoa Project), but the framework will keep his name of SMySQL. Serge Cohen; MySQL Cocoa project, May 30th 2002. --- NEW FILE: MCPConnection.h --- // // SMySQLConnection.h // SMySQL // // Created by serge cohen (ser...@m4...) on Sat Dec 08 2001. // Copyright (c) 2001 MySQL Cocoa project. // // This code is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 of the License, or any later version. // // This code is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // For a copy of the GNU General Public License, visit <http://www.gnu.org/> or // write to the Free Software Foundation, Inc., 59 Temple Place--Suite 330, // Boston, MA 02111-1307, USA. // // More info at <http://mysql-cocoa.sourceforge.net/> // // $Id: MCPConnection.h,v 1.1.2.1 2002/05/30 13:52:01 sergecohen Exp $ #import <Foundation/Foundation.h> #import "mysql.h" //#import <SMySQL/mysql.h> //#import <SMySQL/SMySQL.h> @class SMySQLResult; #define kSMySQL_default_option CLIENT_COMPRESS #define kSMySQLConnectionDefaultSocket MYSQL_UNIX_ADDR #define kSMySQLConnection_error_not_inited 1000 @interface SMySQLConnection : NSObject { MYSQL *mConnection; /*"The inited MySQL connection"*/ BOOL mConnected; /*"Reflect the fact that the connection is already in place or not"*/ NSStringEncoding mEncoding; /*"The encoding used by MySQL server, to ISO-1 default"*/ } /*" Getting default of MySQL "*/ + (NSDictionary *) getMySQLLocales; + (NSStringEncoding) encodingForMySQLEncoding:(const char *) mysqlEncoding; + (NSStringEncoding) defaultMySQLEncoding; /*" Initialisation "*/ - (id) init; // Port to 0 to use the default port - (id) initToHost:(NSString *) host withLogin:(NSString *) login password:(NSString *) pass usingPort:(int) port; - (id) initToSocket:(NSString *) socket withLogin:(NSString *) login password:(NSString *) pass; - (BOOL) setConnectionOption:(int) option withArgument:(id) arg; // Port to 0 to use the default port - (BOOL) connectWithLogin:(NSString *) login password:(NSString *) pass host:(NSString *) host port:(int) port socket:(NSString *) socket; - (BOOL) selectDB:(NSString *) dbName; /*" Errors information "*/ - (NSString *) getLastErrorMessage; - (unsigned int) getLastErrorID; - (BOOL) isConnected; - (BOOL) checkConnection; /*" Queries "*/ - (NSString *) prepareBinaryData:(NSData *) theData; - (NSString *) prepareString:(NSString *) theString; - (SMySQLResult *) queryString:(NSString *) query; - (my_ulonglong) affectedRows; - (my_ulonglong) insertId; /*" Getting description of the database structure "*/ - (SMySQLResult *) listDBs; - (SMySQLResult *) listDBsLike:(NSString *) dbsName; - (SMySQLResult *) listTables; - (SMySQLResult *) listTablesLike:(NSString *) tablesName; // Next method uses SHOW TABLES FROM db to be sure that the db is not changed during this call. - (SMySQLResult *) listTablesFromDB:(NSString *) dbName like:(NSString *) tablesName; - (SMySQLResult *) listFieldsFromTable:(NSString *) tableName; - (SMySQLResult *) listFieldsFromTable:(NSString *) tableName like:(NSString *) fieldsName; /*" Server information and control "*/ - (NSString *) clientInfo; - (NSString *) hostInfo; - (NSString *) serverInfo; - (NSNumber *) protoInfo; - (SMySQLResult *) listProcesses; - (BOOL) killProcess:(unsigned long) pid; //- (BOOL)createDBWithName:(NSString *)dbName; //- (BOOL)dropDBWithName:(NSString *)dbName; /*" Disconnection "*/ - (void) disconnect; - (void) dealloc; /*" String encoding concerns (c string type to NSString). It's unlikely that users of the framework needs to use these methods which are used internally "*/ - (void) setEncoding:(NSStringEncoding) theEncoding; - (NSStringEncoding) encoding; - (const char *) cStringFromString:(NSString *) theString; - (NSString *) stringWithCString:(const char *) theCString; @end --- NEW FILE: MCPResult.h --- // // SMySQLResult.h // SMySQL // // Created by serge cohen (ser...@m4...) on Sat Dec 08 2001. // Copyright (c) 2001 MySQL Cocoa project. // // This code is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 of the License, or any later version. // // This code is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // For a copy of the GNU General Public License, visit <http://www.gnu.org/> or // write to the Free Software Foundation, Inc., 59 Temple Place--Suite 330, // Boston, MA 02111-1307, USA. // // More info at <http://mysql-cocoa.sourceforge.net/> // // $Id: MCPResult.h,v 1.1.2.1 2002/05/30 13:52:01 sergecohen Exp $ #import <Foundation/Foundation.h> #import "mysql.h" //#import <SMySQL/mysql.h> //#import <SMySQL/SMySQL.h> //@class SMySQLRow; @interface SMySQLResult : NSObject { MYSQL_RES *mResult; /*"The MYSQL_RES structure of the C API"*/ NSArray *mNames; /*"An NSArray holding the name of the columns"*/ NSDictionary *mMySQLLocales; /*"A Locales dictionary to define the locales of MySQL"*/ NSStringEncoding mEncoding; /*"The encoding used by MySQL server, to ISO-1 default"*/ } /*" Init used #{only} by #{SMySQLConnection} "*/ - (id)initWithMySQLPtr:(MYSQL *)mySQLPtr encoding:(NSStringEncoding)theEncoding; - (id)initWithResPtr:(MYSQL_RES *)mySQLResPtr encoding:(NSStringEncoding)theEncoding; - (id)init; /*" General info on the result "*/ - (my_ulonglong)numOfRows; - (unsigned int)numOfFields; /*" Getting the rows "*/ - (void)dataSeek:(my_ulonglong)row; - (NSDictionary *)fetchRowAsDictionary; - (NSArray *)fetchRowAsArray; /*" Getting information on columns "*/ - (NSArray *)fetchFieldsName; - (NSArray *)fetchTypesAsArray; - (NSDictionary *)fetchTypesAsDictionary; - (BOOL)isBlobAtIndex:(unsigned int)index; - (BOOL)isBlobForKey:(NSString *)key; /*" Utility method "*/ - (NSString *)description; /*" End of the scope... "*/ - (void)dealloc; /*" Private methods, internam use only "*/ - (const char *)cStringFromString:(NSString *)theString; - (NSString *)stringWithCString:(const char *)theCString; @end --- NEW FILE: MCPResult.m --- // // SMySQLResult.m // SMySQL // // Created by serge cohen (ser...@m4...) on Sat Dec 08 2001. // Copyright (c) 2001 MySQL Cocoa project. // // This code is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 of the License, or any later version. // // This code is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // For a copy of the GNU General Public License, visit <http://www.gnu.org/> or // write to the Free Software Foundation, Inc., 59 Temple Place--Suite 330, // Boston, MA 02111-1307, USA. // // More info at <http://mysql-cocoa.sourceforge.net/> // // $Id: MCPResult.m,v 1.1.2.1 2002/05/30 13:52:01 sergecohen Exp $ #import "SMySQLConnection.h" #import "SMySQLResult.h" @implementation SMySQLResult /*" Hold the results of a query to a MySQL database server. It correspond to the MYSQL_RES structure of the C API, and to the statement handle of the PERL DBI/DBD. Uses the #{mysql_store_result()} function from the C API. This object is generated only by a SMySQLConnection object, in this way (see #{SMySQLConnection} documentation): !{ SMySQLConnection *theConnec = [SMySQLConnection alloc]; SMySQLResult *theRes; NSDictionnary *theDict; NSArray *theColNames; int i, j; theConnec = [theConnec initToHost::albert.com withLogin:@"toto" password:@"albert" port:0]; [theConnec selectDB:@"db1"]; theRes = [theConnec queryString:@"select * from table1"]; theColNames = [theRes fetchFiedlsName]; i = 0; while (theDict = [theRes fetchRowAsDictionary]){ NSLog(@"Row : %d\n", i); for (j=0; j<[theColNames count]; j++) { NSLog(@" Field : %@, contain : %@\n", [theColNames objectAtInex:j], [theDict objectForKey:[theColNames objectAtIndex:j]]); } i++; } } "*/ - (id)initWithMySQLPtr:(MYSQL *)mySQLPtr encoding:(NSStringEncoding)theEncoding /*" initialise a SMySQLResult, it is used internally by SMySQLConnection #{queryString:} method: the only proper way to get a running SMySQLResult object. "*/ { self = [super init]; mEncoding = theEncoding; if (mResult) { mysql_free_result(mResult); mResult = NULL; } if (mNames) { [mNames release]; mNames = NULL; } mResult = mysql_store_result(mySQLPtr); /* if (mResult == NULL) { [self autorelease]; return nil; } */ if (mMySQLLocales == NULL) { mMySQLLocales = [[SMySQLConnection getMySQLLocales] retain]; } return self; } - (id)initWithResPtr:(MYSQL_RES *)mySQLResPtr encoding:(NSStringEncoding)theEncoding /*" This metod it is used internally by SMySQLConnection object when it have already a MYSQL_RES object to initialise SMySQLResult object. Initialise a SMySQLResult with the MYSQL_RES pointer (returned by such a function as mysql_list_dbs). NB: SMySQLResult should be made by using one of the method of SMySQLConnection. "*/ { self = [super init]; mEncoding = theEncoding; if (mResult) { mysql_free_result(mResult); mResult = NULL; } if (mNames) { [mNames release]; mNames = NULL; } mResult = mySQLResPtr; /* if (mResult == NULL) { [self autorelease]; return nil; } */ if (mMySQLLocales == NULL) { mMySQLLocales = [[SMySQLConnection getMySQLLocales] retain]; } return self; } - (id)init /*" Empty init, normaly of NO use to the user, again, SMySQLResult should be made through calls to SMySQLConnection "*/ { self = [super init]; mEncoding = [SMySQLConnection defaultMySQLEncoding]; if (mResult) { mysql_free_result(mResult); mResult = NULL; } if (mNames) { [mNames release]; mNames = NULL; } if (mMySQLLocales == NULL) { mMySQLLocales = [[SMySQLConnection getMySQLLocales] retain]; } return self; } - (my_ulonglong)numOfRows /*" Return the number of rows selected by the query. "*/ { if (mResult) { return mysql_num_rows(mResult); } return 0; } - (unsigned int)numOfFields /*" Return the number of fields selected by the query. "*/ { if (mResult) { return mysql_num_fields(mResult); } return 0; } - (void)dataSeek:(my_ulonglong)row /*" Go to a precise row in the selected result. 0 is the very first row "*/ { my_ulonglong theRow = (row < 0)? 0 : row; theRow = (theRow < [self numOfRows])? theRow : ([self numOfRows]-1); mysql_data_seek(mResult,theRow); return; } - (NSDictionary *)fetchRowAsDictionary /*" Return the next row of the result as a dictionary, the key being the field name, the object a proper object for handling the information in the field (NSString, NSNumber ...). "*/ { MYSQL_ROW theRow; unsigned long *theLengths; MYSQL_FIELD *theField; int i; unsigned int theNumFields; NSMutableDictionary *theDict; if (mResult == NULL) { // If there is no results, returns nil, as after the last row... return nil; } if (mNames == NULL) { [self fetchFieldsName]; } theRow = mysql_fetch_row(mResult); if (theRow == NULL) { return nil; } // NSMutableDictionary *theDict = [NSMutableDictionary dictionaryWithCapacity:theNumFields]; theNumFields = [self numOfFields]; theDict = [NSMutableDictionary dictionaryWithCapacity:theNumFields]; theLengths = mysql_fetch_lengths(mResult); theField = mysql_fetch_fields(mResult); for (i=0; i<theNumFields; i++) { id theCurrentObj,theDataObj; char *theData = calloc(sizeof(char),theLengths[i]+1); memcpy(theData, theRow[i],theLengths[i]); theData[theLengths[i]] = '\0'; // NSLog (@"in fetchRowAsDictionary : field type is %d, for column %d", (int)theField[i].type, (int)i); switch (theField[i].type) { case FIELD_TYPE_TINY: case FIELD_TYPE_SHORT: case FIELD_TYPE_LONG: case FIELD_TYPE_INT24: case FIELD_TYPE_LONGLONG: theCurrentObj = [NSNumber numberWithLong:atol(theData)]; break; case FIELD_TYPE_DECIMAL: case FIELD_TYPE_FLOAT: case FIELD_TYPE_DOUBLE: theCurrentObj = [NSNumber numberWithDouble:atof(theData)]; break; case FIELD_TYPE_TIMESTAMP: // Indeed one should check which format it is (14,12...2) and get the corresponding format string // a switch on theLength[i] would do that... // Here it will crash if it's not default presentation : TIMESTAMP(14) theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y%m%d%H%M%S"]; break; case FIELD_TYPE_DATE: theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d"]; break; case FIELD_TYPE_TIME: // Pass them back as string for the moment... not TIME object in Cocoa (so far) theCurrentObj = [NSString stringWithUTF8String:theData]; case FIELD_TYPE_DATETIME: theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d %H:%M:%S"]; break; case FIELD_TYPE_YEAR: theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y"]; break; case FIELD_TYPE_VAR_STRING: case FIELD_TYPE_STRING: theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; [theCurrentObj autorelease]; break; case FIELD_TYPE_TINY_BLOB: case FIELD_TYPE_BLOB: case FIELD_TYPE_MEDIUM_BLOB: case FIELD_TYPE_LONG_BLOB: theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; break; case FIELD_TYPE_SET: theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; [theCurrentObj autorelease]; break; case FIELD_TYPE_ENUM: theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; [theCurrentObj autorelease]; break; case FIELD_TYPE_NULL: theCurrentObj = nil; break; case FIELD_TYPE_NEWDATE: // Don't know what the format for this type is... theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; [theCurrentObj autorelease]; break; default: NSLog (@"in fetchRowAsDictionary : Unknown type : %d for column %d, send back a NSData object", (int)theField[i].type, (int)i); theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; break; } [theDict setObject:theCurrentObj forKey:[mNames objectAtIndex:i]]; free(theData); } return [NSDictionary dictionaryWithDictionary:theDict]; } - (NSArray *)fetchRowAsArray /*" Return the next row of the result as an array, the index in select field order, the object a proper object for handling the information in the field (NSString, NSNumber ...). "*/ { MYSQL_ROW theRow; unsigned long *theLengths; MYSQL_FIELD *theField; int i; unsigned int theNumFields; NSMutableArray* theArray; if (mResult == NULL) { // If there is no results, returns nil, as after the last row... return nil; } theRow = mysql_fetch_row(mResult); if (theRow == NULL) { return nil; } // A row have been retrieved succesfully, put in in the dictionary theNumFields = [self numOfFields]; theArray = [NSMutableArray arrayWithCapacity:theNumFields]; theLengths = mysql_fetch_lengths(mResult); theField = mysql_fetch_fields(mResult); for (i=0; i<theNumFields; i++) { id theCurrentObj,theDataObj; char *theData = calloc(sizeof(char),theLengths[i]+1); memcpy(theData, theRow[i],theLengths[i]); theData[theLengths[i]] = '\0'; // NSLog (@"in fetchRowAsArray : field type is %d, for column %d", (int)theField[i].type, (int)i); switch (theField[i].type) { case FIELD_TYPE_TINY: case FIELD_TYPE_SHORT: case FIELD_TYPE_LONG: case FIELD_TYPE_INT24: case FIELD_TYPE_LONGLONG: theCurrentObj = [NSNumber numberWithLong:atol(theData)]; break; case FIELD_TYPE_DECIMAL: case FIELD_TYPE_FLOAT: case FIELD_TYPE_DOUBLE: theCurrentObj = [NSNumber numberWithDouble:atof(theData)]; break; case FIELD_TYPE_TIMESTAMP: // Indeed one should check which format it is (14,12...2) and get the corresponding format string // a switch on theLength[i] would do that... // Here it will crash if it's not default presentation : TIMESTAMP(14) theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y%m%d%H%M%S"]; break; case FIELD_TYPE_DATE: theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d"]; break; case FIELD_TYPE_TIME: // Pass them back as string for the moment... not TIME object in Cocoa (so far) theCurrentObj = [NSString stringWithUTF8String:theData]; case FIELD_TYPE_DATETIME: theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y-%m-%d %H:%M:%S"]; break; case FIELD_TYPE_YEAR: theCurrentObj = [NSCalendarDate dateWithString:[NSString stringWithUTF8String:theData] calendarFormat:@"%Y"]; break; case FIELD_TYPE_VAR_STRING: case FIELD_TYPE_STRING: theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; [theCurrentObj autorelease]; break; case FIELD_TYPE_TINY_BLOB: case FIELD_TYPE_BLOB: case FIELD_TYPE_MEDIUM_BLOB: case FIELD_TYPE_LONG_BLOB: theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; break; case FIELD_TYPE_SET: theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; [theCurrentObj autorelease]; break; case FIELD_TYPE_ENUM: theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; [theCurrentObj autorelease]; break; case FIELD_TYPE_NULL: theCurrentObj = nil; break; case FIELD_TYPE_NEWDATE: // Don't know what the format for this type is... theDataObj = [NSData dataWithBytes:theData length:theLengths[i]]; theCurrentObj = [[NSString alloc] initWithData:theDataObj encoding:mEncoding]; [theCurrentObj autorelease]; break; default: NSLog (@"in fetchRowAsArray : Unknown type : %d for column %d, send back a NSData object", (int)theField[i].type, (int)i); theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; break; } [theArray addObject:theCurrentObj]; free(theData); } return [NSArray arrayWithArray:theArray]; } - (NSArray *)fetchFieldsName /*" Generate the mNames if not already generated, and return it. mNames is a NSArray holding the names of the fields(columns) of the results "*/ { unsigned int theNumFields; int i; NSMutableArray *theNamesArray; MYSQL_FIELD *theField; if (mNames) { return mNames; } if (mResult == NULL) { // If no results, give an empty array. Maybe it's better to give a nil pointer? return (mNames = [[NSArray array] retain]); } theNumFields = [self numOfFields]; theNamesArray = [NSMutableArray arrayWithCapacity: theNumFields]; theField = mysql_fetch_fields(mResult); for (i=0; i<theNumFields; i++) { NSString *theName = [self stringWithCString:theField[i].name]; if ((theName) && (![theName isEqualToString:@""])) { [theNamesArray addObject:theName]; } else { [theNamesArray addObject:[NSString stringWithFormat:@"Column %d", i]]; } } return (mNames = [[NSArray arrayWithArray:theNamesArray] retain]); } - (NSArray *)fetchTypesAsArray /*" Return an array of the fields' types. "*/ { unsigned int theNumFields; int i; NSMutableArray *theTypesArray; MYSQL_FIELD *theField; if (mResult == NULL) { // If no results, give an empty array. Maybe it's better to give a nil pointer? return ([NSArray array]); } theNumFields = [self numOfFields]; theTypesArray = [NSMutableArray arrayWithCapacity: theNumFields]; theField = mysql_fetch_fields(mResult); for (i=0; i<theNumFields; i++) { NSString *theType; switch (theField[i].type) { case FIELD_TYPE_TINY: theType = @"tiny"; break; case FIELD_TYPE_SHORT: theType = @"short"; break; case FIELD_TYPE_LONG: theType = @"long"; break; case FIELD_TYPE_INT24: theType = @"int24"; break; case FIELD_TYPE_LONGLONG: theType = @"longlong"; break; case FIELD_TYPE_DECIMAL: theType = @"decimal"; break; case FIELD_TYPE_FLOAT: theType = @"float"; break; case FIELD_TYPE_DOUBLE: theType = @"double"; break; case FIELD_TYPE_TIMESTAMP: theType = @"timestamp"; break; case FIELD_TYPE_DATE: theType = @"date"; break; case FIELD_TYPE_TIME: theType = @"time"; break; case FIELD_TYPE_DATETIME: theType = @"datetime"; break; case FIELD_TYPE_YEAR: theType = @"year"; break; case FIELD_TYPE_VAR_STRING: theType = @"varstring"; break; case FIELD_TYPE_STRING: theType = @"string"; break; case FIELD_TYPE_TINY_BLOB: theType = @"tinyblob"; break; case FIELD_TYPE_BLOB: theType = @"blob"; break; case FIELD_TYPE_MEDIUM_BLOB: theType = @"mediumblob"; break; case FIELD_TYPE_LONG_BLOB: theType = @"longblob"; break; case FIELD_TYPE_SET: theType = @"set"; break; case FIELD_TYPE_ENUM: theType = @"enum"; break; case FIELD_TYPE_NULL: theType = @"null"; break; case FIELD_TYPE_NEWDATE: theType = @"newdate"; break; default: theType = @"unknown"; NSLog (@"in fetchTypesAsArray : Unknown type for column %d of the SMySQLResult, type = %d", (int)i, (int)theField[i].type); break; } [theTypesArray addObject:theType]; } return ([NSArray arrayWithArray:theTypesArray]); } - (NSDictionary*)fetchTypesAsDictionary /*" Return a dictionnary of the fields' types (keys are the fields' names). "*/ { unsigned int theNumFields; int i; NSMutableDictionary *theTypesDict; MYSQL_FIELD *theField; if (mResult == NULL) { // If no results, give an empty array. Maybe it's better to give a nil pointer? return ([NSDictionary dictionary]); } if (mNames == NULL) { [self fetchFieldsName]; } theNumFields = [self numOfFields]; theTypesDict = [NSMutableDictionary dictionaryWithCapacity: theNumFields]; theField = mysql_fetch_fields(mResult); for (i=0; i<theNumFields; i++) { NSString *theType; switch (theField[i].type) { case FIELD_TYPE_TINY: theType = @"tiny"; break; case FIELD_TYPE_SHORT: theType = @"short"; break; case FIELD_TYPE_LONG: theType = @"long"; break; case FIELD_TYPE_INT24: theType = @"int24"; break; case FIELD_TYPE_LONGLONG: theType = @"longlong"; break; case FIELD_TYPE_DECIMAL: theType = @"decimal"; break; case FIELD_TYPE_FLOAT: theType = @"float"; break; case FIELD_TYPE_DOUBLE: theType = @"double"; break; case FIELD_TYPE_TIMESTAMP: theType = @"timestamp"; break; case FIELD_TYPE_DATE: theType = @"date"; break; case FIELD_TYPE_TIME: theType = @"time"; break; case FIELD_TYPE_DATETIME: theType = @"datetime"; break; case FIELD_TYPE_YEAR: theType = @"year"; break; case FIELD_TYPE_VAR_STRING: theType = @"varstring"; break; case FIELD_TYPE_STRING: theType = @"string"; break; case FIELD_TYPE_TINY_BLOB: theType = @"tinyblob"; break; case FIELD_TYPE_BLOB: theType = @"blob"; break; case FIELD_TYPE_MEDIUM_BLOB: theType = @"mediumblob"; break; case FIELD_TYPE_LONG_BLOB: theType = @"longblob"; break; case FIELD_TYPE_SET: theType = @"set"; break; case FIELD_TYPE_ENUM: theType = @"enum"; break; case FIELD_TYPE_NULL: theType = @"null"; break; case FIELD_TYPE_NEWDATE: theType = @"newdate"; break; default: theType = @"unknown"; NSLog (@"in fetchTypesAsDictionary : Unknown type for column %d of the SMySQLResult, type = %d", (int)i, (int)theField[i].type); break; } [theTypesDict setObject:theType forKey:[mNames objectAtIndex:i]]; } return ([NSDictionary dictionaryWithDictionary:theTypesDict]); } - (BOOL)isBlobAtIndex:(unsigned int)index /*" Return YES if the field with the given index is a BLOB. It should be used to discriminates between BLOBs and TEXTs. #{NOT YET IMPLEMENTED}, return YES for both BLOBs and TEXTs... "*/ { BOOL theRet; unsigned int theNumFields; MYSQL_FIELD *theField; if (mResult == NULL) { // If no results, give an empty array. Maybe it's better to give a nil pointer? return (NO); } theNumFields = [self numOfFields]; theField = mysql_fetch_fields(mResult); if (index >= theNumFields) { // Out of range... should raise an exception theRet = NO; } else { switch(theField[index].type) { case FIELD_TYPE_TINY_BLOB: case FIELD_TYPE_BLOB: case FIELD_TYPE_MEDIUM_BLOB: case FIELD_TYPE_LONG_BLOB: theRet = YES; break; default: theRet = NO; break; } } return theRet; } - (BOOL)isBlobForKey:(NSString *)key /*" Return YES if the field (by name) with the given index is a BLOB. It should be used to discriminates between BLOBs and TEXTs. #{NOT YET IMPLEMENTED}, return YES for both BLOBs and TEXTs... "*/ { BOOL theRet; unsigned int theNumFields, index; MYSQL_FIELD *theField; if (mResult == NULL) { // If no results, give an empty array. Maybe it's better to give a nil pointer? return (NO); } if (mNames == NULL) { [self fetchFieldsName]; } theNumFields = [self numOfFields]; theField = mysql_fetch_fields(mResult); if ((index = [mNames indexOfObject:key]) == NSNotFound) { // Non existent key... should raise an exception theRet = NO; } else { switch(theField[index].type) { case FIELD_TYPE_TINY_BLOB: case FIELD_TYPE_BLOB: case FIELD_TYPE_MEDIUM_BLOB: case FIELD_TYPE_LONG_BLOB: theRet = YES; break; default: theRet = NO; break; } } return theRet; } - (NSString *)description /*" Return a (long) string containing the table of results, first line being the fields name, next line(s) the row(s). Useful to have NSLog logging a SMySQLResult (example). "*/ { if (mResult == NULL) { return @"This is an empty SMySQLResult\n"; } else { NSMutableString *theString = [NSMutableString stringWithCapacity:0]; int i, numFields; NSArray *theRow; MYSQL_ROW_OFFSET thePosition; // First line, saying we are displaying a SMySQLResult [theString appendString:@"SMySQLResult:\n"]; // Second line: the field names, tab separated [self fetchFieldsName]; for (i=0; i<((numFields = [mNames count])-1); i++) { [theString appendFormat:@"%@\t", [mNames objectAtIndex:i]]; } [theString appendFormat:@"%@\n", [mNames objectAtIndex:i]]; // Next lines, the records (saving current position to put it back after the full display) thePosition = mysql_row_tell(mResult); [self dataSeek:0]; while (theRow = [self fetchRowAsArray]) { for (i=0; i<(numFields - 1); i++) { [theString appendFormat:@"%@\t", [theRow objectAtIndex:i]]; } [theString appendFormat:@"%@\n", [theRow objectAtIndex:i]]; } // Returning to the proper row mysql_row_seek(mResult,thePosition); return theString; } } - (void)dealloc /* Do one really needs an explanation for this method? Which by the way you should not use... */ { if (mResult) { mysql_free_result(mResult); } if (mNames) { [mNames autorelease]; } if (mMySQLLocales) { [mMySQLLocales autorelease]; } [super dealloc]; return; } - (const char *)cStringFromString:(NSString *)theString /*" For internal use only. Transform a NSString to a C type string (ended with \0) using ethe character set from the SMySQLConnection. Lossy conversions are enabled. "*/ { NSMutableData *theData; if (! theString) { return (const char *)NULL; } theData = [NSMutableData dataWithData:[theString dataUsingEncoding:mEncoding allowLossyConversion:YES]]; [theData increaseLengthBy:1]; return (const char *)[theData bytes]; } - (NSString *)stringWithCString:(const char *)theCString /*" Return a NSString from a C style string encoded with the character set of theSMySQLConnection. "*/ { NSData * theData; NSString * theString; if (theCString == NULL) { return @""; } theData = [NSData dataWithBytes:theCString length:(strlen(theCString))]; theString = [[NSString alloc] initWithData:theData encoding:mEncoding]; if (theString) { [theString autorelease]; } return theString; } @end --- SMySQLConnection.h DELETED --- --- SMySQLResult.h DELETED --- --- SMySQLResult.m DELETED --- |
From: Serge C. <ser...@us...> - 2002-05-30 13:41:51
|
Update of /cvsroot/mysql-cocoa/SMySQL In directory usw-pr-cvs1:/tmp/cvs-serv7990 Added Files: Tag: version-2 MCPConnection.m Removed Files: Tag: version-2 SMySQLConnection.m Log Message: Renamed SMySQLConnection.m to MCPConnection.m --- NEW FILE: MCPConnection.m --- // // SMySQLConnection.m // SMySQL // // Created by serge cohen (ser...@m4...) on Sat Dec 08 2001. // Copyright (c) 2001 MySQL Cocoa project. // // This code is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 of the License, or any later version. // // This code is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // For a copy of the GNU General Public License, visit <http://www.gnu.org/> or // write to the Free Software Foundation, Inc., 59 Temple Place--Suite 330, // Boston, MA 02111-1307, USA. // // More info at <http://mysql-cocoa.sourceforge.net/> // // $Id: MCPConnection.m,v 1.1.2.1 2002/05/30 13:41:47 sergecohen Exp $ #import "SMySQLConnection.h" #import "SMySQLResult.h" @implementation SMySQLConnection /*" This class is used to keep a connection with a MySQL server, it correspond to the MYSQL structure of the C API, or the database handle of the PERL DBI/DBD interface. You have to start any work on a MySQL server by getting a working SMySQLConnection object. Most likely you will use this kind of code: !{ SMySQLConnection *theConnec = [SMySQLConnection alloc]; SMySQLResult *theRes; theConnec = [theConnec initToHost::albert.com withLogin:@"toto" password:@"albert" port:0]; [theConnec selectDB:@"db1"]; theRes = [theConnec queryString:@"select * from table1"]; ... } "*/ + (NSDictionary *) getMySQLLocales /*" Gets a proper Locale dictionary to use formater to parse strings from MySQL. For example strings representing dates should give a proper Locales for use with methods such as NSDate::dateWithNaturalLanguageString: locales: "*/ { NSMutableDictionary *theLocalDict = [NSMutableDictionary dictionaryWithCapacity:12]; [theLocalDict setObject:@"." forKey:@"NSDecimalSeparator"]; return [NSDictionary dictionaryWithDictionary:theLocalDict]; } + (NSStringEncoding) encodingForMySQLEncoding:(const char *) mysqlEncoding /*" Gets a proper NSStringEncoding according to the given MySQL charset. MySQL 4.0 offers this charsets: big5 cp1251 cp1257 croat czech danish dec8 dos estonia euc_kr gb2312 gbk german1 greek hebrew hp8 hungarian koi8_ru koi8_ukr latin1 latin1_de latin2 latin5 sjis swe7 tis620 ujis usa7 win1250 win1251ukr WARNING : incomplete implementation. Please, send your fixes. "*/ { if (!strcmp(mysqlEncoding, "latin1")) { return NSISOLatin1StringEncoding; } if (!strcmp(mysqlEncoding, "latin2")) { return NSISOLatin2StringEncoding; } if (!strcmp(mysqlEncoding, "win1250")) { return NSWindowsCP1250StringEncoding; } if (!strcmp(mysqlEncoding, "cp1251")) { return NSWindowsCP1251StringEncoding; } if (!strcmp(mysqlEncoding, "euc_kr")) { return NSJapaneseEUCStringEncoding; } if (!strcmp(mysqlEncoding, "sjis")) { return NSShiftJISStringEncoding; } // default to iso latin 1, even if it is not exact (throw an exception?) return NSISOLatin1StringEncoding; } + (NSStringEncoding) defaultMySQLEncoding /*" Returns the default charset of the library mysqlclient used. "*/ { return [SMySQLConnection encodingForMySQLEncoding:MYSQL_CHARSET]; } - (id) init /*" Initialise a MySQLConnection without making a connection, most likely useless, except with #{setConnectionOption:withArgument:}. "*/ { self = [super init]; mConnection = mysql_init(NULL); mConnected = NO; if (mConnection == NULL) { [self autorelease]; return nil; } // mEncoding = NSISOLatin1StringEncoding; mEncoding = [SMySQLConnection encodingForMySQLEncoding:mysql_character_set_name(mConnection)]; return self; } - (id) initToHost:(NSString *) host withLogin:(NSString *) login password:(NSString *) pass usingPort:(int) port /*" Initialise a connection using a #{TCP/IP connection} with the given parameters (except if host is set to !{localhost}, in which case uses the default) - host is the hostname or IP adress - login is the user name - pass is the password corresponding to the user name - port is the TCP port to use to connect. If port = 0, uses the default port from mysql.h "*/ { #warning What happens when inited twice the NSObject? self = [super init]; mEncoding = NSISOLatin1StringEncoding; if (mConnected) { // If a the connection is on, disconnect and reset it to default mysql_close(mConnection); mConnection = NULL; } else { } mConnection = mysql_init(mConnection); mConnected = NO; if (mConnection == NULL) { [self autorelease]; return nil; } [self connectWithLogin:login password:pass host:host port:port socket:nil]; return self; } - (id) initToSocket:(NSString *) socket withLogin:(NSString *) login password:(NSString *) pass /*" Initialise a connection using a #{unix socket} with the given parameters - socket is the path to the socket - login is the user name - pass is the password corresponding to the user name "*/ { #warning What happens when inited twice the NSObject? self = [super init]; mEncoding = NSISOLatin1StringEncoding; if (mConnected) { // If a the connection is on, disconnect and reset it to default mysql_close(mConnection); mConnection = NULL; } else { } mConnection = mysql_init(mConnection); mConnected = NO; if (mConnection == NULL) { [self autorelease]; return nil; } [self connectWithLogin:login password:pass host:NULL port:0 socket:socket]; return self; } - (BOOL) setConnectionOption:(int) option withArgument:(id) arg /*" #{NOT YET IMPLEMENTED} This method is to be used for getting special option for a connection, in which case the SMySQLConnection has to be inited with the init method, then option are selected, finally connection is done using one of the connect methods: !{ SMySQLConnection *theConnect = [[SMySQLConnection alloc] init]; [theConnect setConnectionOption: option withArgument: arg]; [theConnect connectToHost:albert.com withLogin:@"toto" password:@"albert" port:0]; .... } "*/ { // So far do nothing except for testing if it's proper time for setting option // What about if some option where setted and a connection is made again with connectTo... if ((mConnected) || (! mConnection)) { return FALSE; } return YES; } - (BOOL) connectWithLogin:(NSString *) login password:(NSString *) pass host:(NSString *) host port:(int) port socket:(NSString *) socket /*" The method used by #{initToHost:withLogin:password:usingPort:} and #{initToSocket:withLogin:password:}. Same information and use of the parameters: - login is the user name - pass is the password corresponding to the user name - host is the hostname or IP adress - port is the TCP port to use to connect. If port = 0, uses the default port from mysql.h - socket is the path to the socket (for the localhost) The socket is used if the host is set to !{@"localhost"}, to an empty or a !{nil} string For the moment the implementation might not be safe if you have a nil pointer to one of the NSString* variables (underestand: I don't know what the result will be). "*/ { #warning What to do if one of the string is a nil pointer? const char *theLogin = [self cStringFromString:login]; const char *theHost = [self cStringFromString:host]; const char *thePass = [self cStringFromString:pass]; const char *theSocket = [self cStringFromString:socket]; void *theRet; if (mConnected) { // Disconnect if it was already connected mysql_close(mConnection); mConnection = NULL; mConnected = NO; [self init]; } if ([host isEqualToString:@""]) { theHost = NULL; } if (theSocket == NULL) { theSocket = kSMySQLConnectionDefaultSocket; } theRet = mysql_real_connect(mConnection, theHost, theLogin, thePass, NULL, port, theSocket, kSMySQL_default_option); if (theRet != mConnection) { return mConnected = NO; } mEncoding = [SMySQLConnection encodingForMySQLEncoding:mysql_character_set_name(mConnection)]; return mConnected = YES; } - (BOOL) selectDB:(NSString *) dbName /*" Selects a database to work with. The SMySQLConnection object needs to be properly inited and connected to a server. If a connection is not yet set or the selection of the database didn't work, returns NO. Returns YES in normal cases where the database is properly selected. So far, if dbName is a nil pointer it will return NO (as if it cannot connect), most likely this will throw an exception in the future. "*/ { if (dbName == nil) { #warning Should throw an exception, illegal string pointer (nil) // Here we should throw an exception, impossible to select a databse if the string is indeed a nil pointer return NO; } if (mConnected) { const char *theDBName = [self cStringFromString:dbName]; if (mysql_select_db(mConnection, theDBName) == NULL) { return YES; } } return NO; } - (NSString *) getLastErrorMessage /*" Returns a string with the last MySQL error message on the connection. "*/ { if (mConnection) { return [self stringWithCString:mysql_error(mConnection)]; } else { return [NSString stringWithString:@"No connection initailized yet (MYSQL* still NULL)\n"]; } } - (unsigned int) getLastErrorID /*" Returns the ErrorID of the last MySQL error on the connection. "*/ { if (mConnection) { return mysql_errno(mConnection); } return kSMySQLConnection_error_not_inited; } - (BOOL) isConnected /*" Returns YES if the SMySQLConnection is connected to a DB, NO otherwise. "*/ { return mConnected; } - (BOOL)checkConnection /*" Checks if the connection to the server is still on. If not, tries to reconnect (changing no parameters from the MYSQL pointer). This method just uses mysql_ping(). "*/ { return (BOOL)(! mysql_ping(mConnection)); } - (NSString *) prepareBinaryData:(NSData *) theData /*" Takes a NSData object and transform it in a proper string for sending to the server in between quotes. "*/ { const char *theCDataBuffer = [theData bytes]; unsigned int theLength = [theData length]; char *theCEscBuffer = (char *)calloc(sizeof(char),(theLength*2) + 1); NSString *theReturn; mysql_real_escape_string(mConnection, theCEscBuffer, theCDataBuffer, theLength); theReturn = [self stringWithCString:theCEscBuffer]; free (theCEscBuffer); return theReturn; } - (NSString *) prepareString:(NSString *) theString /*" Takes a string and escape any special character (like single quote : ') so that the string can be used directly in a query. "*/ { const char *theCStringBuffer = [self cStringFromString:theString]; unsigned int theLength = strlen(theCStringBuffer); char *theCEscBuffer = (char *)calloc(sizeof(char),(theLength * 2) + 1); NSString *theReturn; mysql_real_escape_string(mConnection, theCEscBuffer, theCStringBuffer, theLength); theReturn = [self stringWithCString:theCEscBuffer]; free (theCEscBuffer); return theReturn; } - (SMySQLResult *) queryString:(NSString *) query /*" Takes a query string and return an SMySQLResult object holding the result of the query. The returned SMySQLResult is not retained, the client is responsible for that (it's autoreleased before being returned) Note that if you want to use this method with binary data (in the query), you should use !{prepareBinaryData:} to include the binary data in the query string. "*/ { SMySQLResult *theResult = [SMySQLResult alloc]; const char *theCQuery = [self cStringFromString:query]; int theQueryCode; if ((theQueryCode = mysql_query(mConnection, theCQuery)) == NULL) { if (mysql_field_count(mConnection) != 0) { theResult = [theResult initWithMySQLPtr:mConnection encoding:mEncoding]; } else { // NSLog (@"Query worked but gives no output\n"); [theResult init]; } } else { NSLog (@"Problem in queryString error code is : %d, query is : %s -in ObjC : %@-\n", theQueryCode, theCQuery, query); theResult = [theResult init]; } if (theResult) { [theResult autorelease]; } return theResult; } - (my_ulonglong) affectedRows /*" Returns the number of affected rows by the last query. "*/ { if (mConnected) { return mysql_affected_rows(mConnection); } return 0; } - (my_ulonglong) insertId /*" If the last query was an insert in a table having a autoindex column, returns the id (autoindexed field) of the last row inserted. "*/ { if (mConnected) { return mysql_insert_id(mConnection); } return 0; } - (SMySQLResult *) listDBs /*" Just a fast wrapper for the more complex !{listDBsWithPattern:} method. "*/ { return [self listDBsLike:nil]; } - (SMySQLResult *) listDBsLike:(NSString *) dbsName /*" Returns a list of database which name correspond to the SQL regular expression in 'pattern'. The comparison is done with wild card extension : % and _. The result should correspond to the queryString:@"SHOW databases [LIKE wild]"; but implemented with mysql_list_dbs. If an empty string or nil is passed as pattern, all databases will be shown. "*/ { SMySQLResult *theResult = [SMySQLResult alloc]; MYSQL_RES *theResPtr; if ((dbsName == nil) || ([dbsName isEqualToString:@""])) { if (theResPtr = mysql_list_dbs(mConnection, NULL)) { [theResult initWithResPtr: theResPtr encoding: mEncoding]; } else { [theResult init]; } } else { const char *theCDBsName = (const char *)[[dbsName dataUsingEncoding: mEncoding allowLossyConversion: YES] bytes]; if (theResPtr = mysql_list_dbs(mConnection, theCDBsName)) { [theResult initWithResPtr: theResPtr encoding: mEncoding]; } else { [theResult init]; } } if (theResult) { [theResult autorelease]; } return theResult; } - (SMySQLResult *) listTables /*" Make sure a DB is selected (with !{selectDB} method) first. "*/ { return [self listTablesLike:nil]; } - (SMySQLResult *) listTablesLike:(NSString *) tablesName /*" From within a database, give back the list of table which name correspond to tablesName (with wild card %, _ extension). Correspond to queryString:@"SHOW tables [LIKE wild]"; uses mysql_list_tables function. If an empty string or nil is passed as tablesName, all tables will be shown. WARNING: #{produce an error if no databases are selected} (with !{selectDB:} for example). "*/ { SMySQLResult *theResult = [SMySQLResult alloc]; MYSQL_RES *theResPtr; if ((tablesName == nil) || ([tablesName isEqualToString:@""])) { if (theResPtr = mysql_list_tables(mConnection, NULL)) { [theResult initWithResPtr: theResPtr encoding: mEncoding]; } else { [theResult init]; } } else { const char *theCTablesName = (const char *)[[tablesName dataUsingEncoding: mEncoding allowLossyConversion: YES] bytes]; if (theResPtr = mysql_list_tables(mConnection, theCTablesName)) { [theResult initWithResPtr: theResPtr encoding: mEncoding]; } else { [theResult init]; } } if (theResult) { [theResult autorelease]; } return theResult; } - (SMySQLResult *) listTablesFromDB:(NSString *) dbName like:(NSString *) tablesName /*" List tables in DB specified by dbName and corresponding to pattern. This method indeed issues a !{SHOW TABLES FROM dbName LIKE ...} query to the server. This is done this way to make sure the selected DB is not changed by this method. "*/ { SMySQLResult *theResult; if ((tablesName == nil) || ([tablesName isEqualToString:@""])) { NSString *theQuery = [NSString stringWithFormat:@"SHOW TABLES FROM %@", dbName]; theResult = [self queryString:theQuery]; } else { NSString *theQuery = [NSString stringWithFormat:@"SHOW COLUMNS FROM %@ LIKE '%@'", dbName, tablesName]; theResult = [self queryString:theQuery]; } return theResult; } - (SMySQLResult *)listFieldsFromTable:(NSString *)tableName /*" Just a fast wrapper for the more complex list !{listFieldsWithPattern:forTable:} method. "*/ { return [self listFieldsFromTable:tableName like:nil]; } - (SMySQLResult *) listFieldsFromTable:(NSString *) tableName like:(NSString *) fieldsName /*" Show all the fields of the table tableName which name correspond to pattern (with wild card expansion : %,_). Indeed, and as recommanded from mysql reference, this method is NOT using mysql_list_fields but the !{queryString:} method. If an empty string or nil is passed as fieldsName, all fields (of tableName) will be returned. "*/ { SMySQLResult *theResult; if ((fieldsName == nil) || ([fieldsName isEqualToString:@""])) { NSString *theQuery = [NSString stringWithFormat:@"SHOW COLUMNS FROM %@", tableName]; theResult = [self queryString:theQuery]; } else { NSString *theQuery = [NSString stringWithFormat:@"SHOW COLUMNS FROM %@ LIKE '%@'", tableName, fieldsName]; theResult = [self queryString:theQuery]; } return theResult; } - (NSString *) clientInfo /*" Returns a string giving the client library version. "*/ { return [self stringWithCString:mysql_get_client_info()]; } - (NSString *) hostInfo /*" Returns a string giving information on the host of the DB server. "*/ { return [self stringWithCString:mysql_get_host_info(mConnection)]; } - (NSString *) serverInfo /*" Returns a string giving the server version. "*/ { if (mConnected) { return [self stringWithCString: mysql_get_server_info(mConnection)]; } return @""; } - (NSNumber *) protoInfo /*" Returns the number of the protocole used to transfer info from server to client "*/ { return [NSNumber numberWithUnsignedInt:mysql_get_proto_info(mConnection)]; } - (SMySQLResult *) listProcesses /*" Lists active process "*/ { SMySQLResult *theResult = [SMySQLResult alloc]; MYSQL_RES *theResPtr; if (theResPtr = mysql_list_processes(mConnection)) { [theResult initWithResPtr:theResPtr encoding:mEncoding]; } else { [theResult init]; } if (theResult) { [theResult autorelease]; } return theResult; } /* - (BOOL)createDBWithName:(NSString *)dbName { const char *theDBName = [dbName UTF8String]; if ((mConnected) && (! mysql_create_db(mConnection, theDBName))) { return YES; } return NO; } - (BOOL)dropDBWithName:(NSString *)dbName { const char *theDBName = [dbName UTF8String]; if ((mConnected) && (! mysql_drop_db(mConnection, theDBName))) { return YES; } return NO; } */ - (BOOL) killProcess:(unsigned long) pid /*" Kills the process with the given pid. The users needs the #{Process_priv} privilege. "*/ { int theErrorCode; theErrorCode = mysql_kill(mConnection, pid); return (theErrorCode) ? NO : YES; } - (void) disconnect /*" Disconnects a connected SMySQLConnection object; used by #{-dealloc} method. "*/ { if (mConnected) { mysql_close(mConnection); mConnection = NULL; } mConnected = NO; return; } - (void)dealloc /*" The standard deallocation method for SMySQLConnection objects. "*/ { [self disconnect]; [super dealloc]; return; } - (void) setEncoding:(NSStringEncoding) theEncoding /*" Sets the encoding used by the server for data transfert. Used to make sure the output of the query result is ok even for non-ascii characters The character set (encoding) used by the db is passed to the SMySQLConnection object upon connection, so most likely the encoding (from -encoding) method is already the proper one. That is to say : It's unlikely you will need to call this method directly, and #{if ever you use it, do it at your own risks}. "*/ { mEncoding = theEncoding; } - (NSStringEncoding) encoding /*" Gets the encoding for the connection "*/ { return mEncoding; } - (const char *) cStringFromString:(NSString *) theString /*" For internal use only. Transforms a NSString to a C type string (ending with \0) using the character set from the SMySQLConnection. Lossy conversions are enabled. "*/ { NSMutableData *theData; if (! theString) { return (const char *)NULL; } theData = [NSMutableData dataWithData:[theString dataUsingEncoding:mEncoding allowLossyConversion:YES]]; [theData increaseLengthBy:1]; return (const char *)[theData bytes]; } - (NSString *) stringWithCString:(const char *) theCString /*" Returns a NSString from a C style string encoded with the character set of theSMySQLConnection. "*/ { NSData * theData; NSString * theString; if (theCString == NULL) { return @""; } theData = [NSData dataWithBytes:theCString length:(strlen(theCString))]; theString = [[NSString alloc] initWithData:theData encoding:mEncoding]; if (theString) { [theString autorelease]; } return theString; } @end --- SMySQLConnection.m DELETED --- |
From: Serge C. <ser...@us...> - 2002-05-30 08:32:37
|
Update of /cvsroot/mysql-cocoa/SMySQL In directory usw-pr-cvs1:/tmp/cvs-serv5380 Modified Files: SMySQLConnection.h SMySQLConnection.m Log Message: Added a prepareString method to SMySQLConnection. Serge Cohen; MySQL Cocoa project, May 30th 2002. Index: SMySQLConnection.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQLConnection.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SMySQLConnection.h 15 May 2002 11:07:30 -0000 1.9 --- SMySQLConnection.h 30 May 2002 08:32:33 -0000 1.10 *************** *** 75,78 **** --- 75,79 ---- - (NSString *) prepareBinaryData:(NSData *) theData; + - (NSString *) prepareString:(NSString *) theString; - (SMySQLResult *) queryString:(NSString *) query; Index: SMySQLConnection.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQLConnection.m,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SMySQLConnection.m 15 May 2002 11:07:30 -0000 1.9 --- SMySQLConnection.m 30 May 2002 08:32:34 -0000 1.10 *************** *** 331,336 **** { const char *theCDataBuffer = [theData bytes]; ! unsigned int theLength; ! char *theCEscBuffer = (char *)calloc(sizeof(char),((theLength = [theData length])*2) + 1); NSString *theReturn; --- 331,336 ---- { const char *theCDataBuffer = [theData bytes]; ! unsigned int theLength = [theData length]; ! char *theCEscBuffer = (char *)calloc(sizeof(char),(theLength*2) + 1); NSString *theReturn; *************** *** 342,345 **** --- 342,362 ---- + - (NSString *) prepareString:(NSString *) theString + /*" + Takes a string and escape any special character (like single quote : ') so that the string can be used directly in a query. + "*/ + { + const char *theCStringBuffer = [self cStringFromString:theString]; + unsigned int theLength = strlen(theCStringBuffer); + char *theCEscBuffer = (char *)calloc(sizeof(char),(theLength * 2) + 1); + NSString *theReturn; + + mysql_real_escape_string(mConnection, theCEscBuffer, theCStringBuffer, theLength); + theReturn = [self stringWithCString:theCEscBuffer]; + free (theCEscBuffer); + return theReturn; + } + + - (SMySQLResult *) queryString:(NSString *) query /*" *************** *** 358,362 **** } else { ! NSLog (@"Query worked but gives no output\n"); [theResult init]; } --- 375,379 ---- } else { ! // NSLog (@"Query worked but gives no output\n"); [theResult init]; } |