mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-29 13:21:35 +02:00
Merged revisions 4032,4043 via svnmerge from
svn+ssh://joost@svn.freepascal.org/FPC/svn/fpc/trunk ........ r4032 | joost | 2006-07-01 12:17:22 +0200 (Sat, 01 Jul 2006) | 1 line + dbconst.pp should contain resourcestrings ........ r4043 | joost | 2006-07-01 23:25:52 +0200 (Sat, 01 Jul 2006) | 2 lines + Escape strings in string-parameters + fix in the MySQL-bindings ........ git-svn-id: branches/fixes_2_0@4045 -
This commit is contained in:
parent
2d34f1ce50
commit
0bc6462da5
@ -18,7 +18,7 @@ unit dbconst;
|
|||||||
|
|
||||||
Interface
|
Interface
|
||||||
|
|
||||||
Const
|
Resourcestring
|
||||||
SActiveDataset = 'Operation cannot be performed on an active dataset';
|
SActiveDataset = 'Operation cannot be performed on an active dataset';
|
||||||
SBadParamFieldType = 'Bad fieldtype for parameter "%s".';
|
SBadParamFieldType = 'Bad fieldtype for parameter "%s".';
|
||||||
SCantSetAutoIncFields = 'AutoInc Fields are read-only';
|
SCantSetAutoIncFields = 'AutoInc Fields are read-only';
|
||||||
|
@ -71,6 +71,9 @@ Type
|
|||||||
procedure DoInternalDisconnect; override;
|
procedure DoInternalDisconnect; override;
|
||||||
function GetHandle : pointer; override;
|
function GetHandle : pointer; override;
|
||||||
|
|
||||||
|
function GetAsSQLText(Field : TField) : string; overload; virtual;
|
||||||
|
function GetAsSQLText(Param : TParam) : string; overload; virtual;
|
||||||
|
|
||||||
Function AllocateCursorHandle : TSQLCursor; override;
|
Function AllocateCursorHandle : TSQLCursor; override;
|
||||||
Procedure DeAllocateCursorHandle(var cursor : TSQLCursor); override;
|
Procedure DeAllocateCursorHandle(var cursor : TSQLCursor); override;
|
||||||
Function AllocateTransactionHandle : TSQLHandle; override;
|
Function AllocateTransactionHandle : TSQLHandle; override;
|
||||||
@ -184,6 +187,39 @@ begin
|
|||||||
MySQlError(Nil,SErrServerConnectFailed,Self);
|
MySQlError(Nil,SErrServerConnectFailed,Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TConnectionName.GetAsSQLText(Field : TField) : string;
|
||||||
|
|
||||||
|
var esc_str : pchar;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if (not assigned(field)) or field.IsNull then Result := 'Null'
|
||||||
|
else if field.DataType = ftString then
|
||||||
|
begin
|
||||||
|
Getmem(esc_str,sizeof(field.asstring)*2+1);
|
||||||
|
mysql_real_escape_string(FMySQL,esc_str,pchar(field.asstring),length(field.asstring));
|
||||||
|
Result := '''' + esc_str + '''';
|
||||||
|
Freemem(esc_str);
|
||||||
|
end
|
||||||
|
else Result := inherited GetAsSqlText(field);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TConnectionName.GetAsSQLText(Param: TParam) : string;
|
||||||
|
|
||||||
|
var esc_str : pchar;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if (not assigned(param)) or param.IsNull then Result := 'Null'
|
||||||
|
else if param.DataType = ftString then
|
||||||
|
begin
|
||||||
|
Getmem(esc_str,sizeof(param.asstring)*2+1);
|
||||||
|
mysql_real_escape_string(FMySQL,esc_str,pchar(param.asstring),length(param.asstring));
|
||||||
|
Result := '''' + esc_str + '''';
|
||||||
|
Freemem(esc_str);
|
||||||
|
end
|
||||||
|
else Result := inherited GetAsSqlText(Param);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TConnectionName.ConnectToServer;
|
procedure TConnectionName.ConnectToServer;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
|
@ -1568,7 +1568,7 @@ begin
|
|||||||
pointer(mysql_ping) := GetProcedureAddress(MysqlLibraryHandle,'mysql_ping');
|
pointer(mysql_ping) := GetProcedureAddress(MysqlLibraryHandle,'mysql_ping');
|
||||||
pointer(mysql_query) := GetProcedureAddress(MysqlLibraryHandle,'mysql_query');
|
pointer(mysql_query) := GetProcedureAddress(MysqlLibraryHandle,'mysql_query');
|
||||||
pointer(mysql_real_connect) := GetProcedureAddress(MysqlLibraryHandle,'mysql_real_connect');
|
pointer(mysql_real_connect) := GetProcedureAddress(MysqlLibraryHandle,'mysql_real_connect');
|
||||||
pointer(mysql_real_escape_string) := GetProcedureAddress(MysqlLibraryHandle,'mysql_real_escape_String');
|
pointer(mysql_real_escape_string) := GetProcedureAddress(MysqlLibraryHandle,'mysql_real_escape_string');
|
||||||
pointer(mysql_real_query) := GetProcedureAddress(MysqlLibraryHandle,'mysql_real_query');
|
pointer(mysql_real_query) := GetProcedureAddress(MysqlLibraryHandle,'mysql_real_query');
|
||||||
pointer(mysql_refresh) := GetProcedureAddress(MysqlLibraryHandle,'mysql_refresh');
|
pointer(mysql_refresh) := GetProcedureAddress(MysqlLibraryHandle,'mysql_refresh');
|
||||||
// pointer(mysql_reload) := GetProcedureAddress(MysqlLibraryHandle,'mysql_reload');
|
// pointer(mysql_reload) := GetProcedureAddress(MysqlLibraryHandle,'mysql_reload');
|
||||||
|
Loading…
Reference in New Issue
Block a user