Changeset 21 for trunk/DbEngines
- Timestamp:
- Mar 23, 2018, 3:06:47 PM (7 years ago)
- Location:
- trunk/DbEngines
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DbEngines/UEngineMySQL.pas
r20 r21 19 19 public 20 20 SqlDatabase: TSqlDatabase; 21 procedure Query( DbRows: TDbRows; Text: string); override;21 procedure Query(Text: string; DbRows: TDbRows = nil); override; 22 22 constructor Create; override; 23 23 destructor Destroy; override; … … 87 87 if DbRows2.Count > 0 then begin 88 88 TypeName := TDictionaryStringString(DbRows2[0]).Values['Name']; 89 NewField.DataType := Table.DbClient.ClientType.DataTypes. FindByName(TypeName);89 NewField.DataType := Table.DbClient.ClientType.DataTypes.SearchByName(TypeName); 90 90 if not Assigned(NewField.DataType) then 91 NewField.DataType := Table.DbClient.ClientType.DataTypes. FindByType(ftString);91 NewField.DataType := Table.DbClient.ClientType.DataTypes.SearchByType(ftString); 92 92 end else begin 93 93 // Use string as default 94 NewField.DataType := Table.DbClient.ClientType.DataTypes. FindByType(ftString);94 NewField.DataType := Table.DbClient.ClientType.DataTypes.SearchByType(ftString); 95 95 end; 96 96 Table.Fields.Add(NewField); … … 125 125 end; 126 126 127 procedure TDatabaseMySQL.Query( DbRows: TDbRows; Text: string);127 procedure TDatabaseMySQL.Query(Text: string; DbRows: TDbRows = nil); 128 128 begin 129 129 SqlDatabase.Query(DbRows, Text); -
trunk/DbEngines/UEngineXML.pas
r20 r21 30 30 procedure LoadFromFile(FileName: string); 31 31 procedure SaveToFile(FileName: string); 32 function GetNextPart(var Text: string ): string;32 function GetNextPart(var Text: string; Separator: string = ' '): string; 33 33 protected 34 34 public 35 procedure Query( DbRows: TDbRows; Text: string); override;35 procedure Query(Text: string; DbRows: TDbRows = nil); override; 36 36 procedure LoadTables(Tables: TTables); override; 37 37 procedure Load; override; … … 158 158 begin 159 159 Field.Name := ReadString(Node, 'Name', ''); 160 Field.DataType := Field.Table.DbClient.ClientType.DataTypes. FindByType(TFieldType(ReadInteger(Node, 'Type', 0)));160 Field.DataType := Field.Table.DbClient.ClientType.DataTypes.SearchByType(TFieldType(ReadInteger(Node, 'Type', 0))); 161 161 Field.TextBefore := ReadString(Node, 'TextBefore', ''); 162 162 Field.TextAfter := ReadString(Node, 'TextAfter', ''); … … 296 296 SaveNodeTables(Tables, NewNode); 297 297 end; 298 ForceDirectories(ExtractFileDir(FileName)); 298 if Pos(DirectorySeparator, FileName) > 0 then 299 ForceDirectories(ExtractFileDir(FileName)); 299 300 WriteXMLFile(Doc, FileName); 300 301 finally … … 303 304 end; 304 305 305 function TDatabaseXML.GetNextPart(var Text: string ): string;306 begin 307 if Pos( ' ', Text) > 0 then begin308 Result := Trim(Copy(Text, 1, Pos( ' ', Text) - 1));309 Delete(Text, 1, Pos( ' ', Text));306 function TDatabaseXML.GetNextPart(var Text: string; Separator: string = ' '): string; 307 begin 308 if Pos(Separator, Text) > 0 then begin 309 Result := Trim(Copy(Text, 1, Pos(Separator, Text) - Length(Separator))); 310 Delete(Text, 1, Pos(Separator, Text)); 310 311 end else begin 311 312 Result := Text; … … 314 315 end; 315 316 316 procedure TDatabaseXML.Query( DbRows: TDbRows; Text: string);317 procedure TDatabaseXML.Query(Text: string; DbRows: TDbRows = nil); 317 318 var 318 319 Command: string; … … 348 349 end else raise Exception.Create('Unsupported columns ' + Columns + ' specification'); 349 350 end else raise Exception.Create('Table ' + TableName + ' not found.'); 350 end else raise Exception.Create('Unsupported SQL command ' + Command); 351 end else 352 if Command = 'CREATE' then begin 353 Command := GetNextPart(Text); 354 if Command = 'TABLE' then begin 355 TableName := GetNextPart(Text); 356 Table := TTable.Create; 357 Table.Name := TableName; 358 Table.DbClient := Self; 359 Tables.Add(Table);; 360 end else raise Exception.Create('TABLE keyword expected'); 361 end else 362 if Command = 'DROP' then begin 363 Command := GetNextPart(Text); 364 if Command = 'TABLE' then begin 365 TableName := GetNextPart(Text); 366 Table := Tables.SearchByName(TableName); 367 if Assigned(Table) then Tables.Remove(Table) 368 else raise Exception.Create('Table ' + TableName + ' not found'); 369 end else raise Exception.Create('TABLE keyword expected'); 370 end else 371 raise Exception.Create('Unsupported SQL command ' + Command); 351 372 end; 352 373 353 374 procedure TDatabaseXML.LoadTables(Tables: TTables); 354 375 begin 355 inherited; 356 376 Tables.Assign(Self.Tables); 357 377 end; 358 378 359 379 procedure TDatabaseXML.Load; 360 380 begin 381 FileName := TDbConnectParamsXml(ConnectProfile.Params).FileName; 361 382 if FileExists(FileName) then 362 383 LoadFromFile(FileName);
Note:
See TracChangeset
for help on using the changeset viewer.