Browse Source

* Implemented Port property (bug 10533)

git-svn-id: trunk@10344 -
joost 17 years ago
parent
commit
983e723262

+ 4 - 3
packages/fcl-db/src/sqldb/mysql/mysqlconn.inc

@@ -134,6 +134,7 @@ Type
     property KeepConnection;
     property KeepConnection;
     property LoginPrompt;
     property LoginPrompt;
     property Params;
     property Params;
+    property Port stored false;
     property OnLogin;
     property OnLogin;
   end;
   end;
 
 
@@ -213,12 +214,12 @@ end;
 procedure TConnectionName.ConnectMySQL(var HMySQL : PMySQL;H,U,P : pchar);
 procedure TConnectionName.ConnectMySQL(var HMySQL : PMySQL;H,U,P : pchar);
 
 
 Var
 Var
-  Port : Cardinal;
+  APort : Cardinal;
 
 
 begin
 begin
   HMySQL := mysql_init(HMySQL);
   HMySQL := mysql_init(HMySQL);
-  Port:=Abs(StrToIntDef(Params.Values['Port'],0));
-  HMySQL:=mysql_real_connect(HMySQL,PChar(H),PChar(U),Pchar(P),Nil,Port,Nil,0);
+  APort:=Abs(StrToIntDef(Params.Values['Port'],0));
+  HMySQL:=mysql_real_connect(HMySQL,PChar(H),PChar(U),Pchar(P),Nil,APort,Nil,0);
   If (HMySQL=Nil) then
   If (HMySQL=Nil) then
     MySQlError(Nil,SErrServerConnectFailed,Self);
     MySQlError(Nil,SErrServerConnectFailed,Self);
 end;
 end;

+ 17 - 1
packages/fcl-db/src/sqldb/sqldb.pp

@@ -85,7 +85,9 @@ type
     FHostName            : string;
     FHostName            : string;
     FCharSet             : string;
     FCharSet             : string;
     FRole                : String;
     FRole                : String;
-
+    
+    function GetPort: cardinal;
+    procedure Setport(const AValue: cardinal);
   protected
   protected
     FConnOptions         : TConnOptions;
     FConnOptions         : TConnOptions;
     procedure GetDBInfo(const SchemaType : TSchemaType; const SchemaObjectName, ReturnField : string; List: TStrings);
     procedure GetDBInfo(const SchemaType : TSchemaType; const SchemaObjectName, ReturnField : string; List: TStrings);
@@ -119,6 +121,7 @@ type
     function GetSchemaInfoSQL(SchemaType : TSchemaType; SchemaObjectName, SchemaPattern : string) : string; virtual;
     function GetSchemaInfoSQL(SchemaType : TSchemaType; SchemaObjectName, SchemaPattern : string) : string; virtual;
     procedure LoadBlobIntoBuffer(FieldDef: TFieldDef;ABlobBuf: PBufBlobField; cursor: TSQLCursor; ATransaction : TSQLTransaction); virtual; abstract;
     procedure LoadBlobIntoBuffer(FieldDef: TFieldDef;ABlobBuf: PBufBlobField; cursor: TSQLCursor; ATransaction : TSQLTransaction); virtual; abstract;
     function RowsAffected(cursor: TSQLCursor): TRowsCount; virtual;
     function RowsAffected(cursor: TSQLCursor): TRowsCount; virtual;
+    property port: cardinal read GetPort write Setport;
   public
   public
     property Handle: Pointer read GetHandle;
     property Handle: Pointer read GetHandle;
     destructor Destroy; override;
     destructor Destroy; override;
@@ -543,6 +546,19 @@ begin
   end;
   end;
 end;
 end;
 
 
+function TSQLConnection.GetPort: cardinal;
+begin
+  result := StrToIntDef(Params.Values['Port'],0);
+end;
+
+procedure TSQLConnection.Setport(const AValue: cardinal);
+begin
+  if AValue<>0 then
+    params.Values['Port']:=IntToStr(AValue)
+  else with params do if IndexOfName('Port') > -1 then
+    Delete(IndexOfName('Port'));
+end;
+
 procedure TSQLConnection.GetDBInfo(const SchemaType : TSchemaType; const SchemaObjectName, ReturnField : string; List: TStrings);
 procedure TSQLConnection.GetDBInfo(const SchemaType : TSchemaType; const SchemaObjectName, ReturnField : string; List: TStrings);
 
 
 var qry : TCustomSQLQuery;
 var qry : TCustomSQLQuery;