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
|