Closed GoogleCodeExporter closed 9 years ago
TSimpleSQL = record DBConfigID: Integer; Sql: string; // &TABLEName=AAA;$where= where xxx; Args: string; Params: array of Variant; //or TArray<Variant> sql Params,x-supperobject dont support it // procedure Clear; // function ToString(): string; procedure FromJson(const jsonStr: string); end; procedure TSimpleSQL.Clear; begin DBConfigID := 0; Sql := ''; SetLength(Args, 0); SetLength(Params, 0); end; procedure TSimpleSQL.FromJson(const jsonStr: string); var json: ISuperObject; begin Self.Clear; Self := TSuperRecord<TSimpleSQL>.FromJSON(jsonStr); end; function TSimpleSQL.ToString: string; var json: ISuperObject; begin Result := ''; // json := TSuperRecord<TSimpleSQL>.AsJSONObject(Self); // if Assigned(json) then // Result := json.AsJSON; Result := TSuperRecord<TSimpleSQL>.AsJSON(Self); end; sample: procedure TForm7.btn1Click(Sender: TObject); var SimpleSQL,SimpleSQL2:TSimpleSQL; begin SimpleSQL.Clear; SimpleSQL.DBConfigID := 1234; SimpleSQL.Sql := 'SELECT * FROM TABLE WHERE ID=''My ID'''; SimpleSQL.Args := '$Name=''1313'';$VALUE=DATEEW'; SetLength(SimpleSQL.Params,5); SimpleSQL.Params[0] := True; SimpleSQL.Params[1] := 4566; SimpleSQL.Params[2] := 'abewegewgew'; SimpleSQL.Params[3] := 13324; SimpleSQL.Params[5] := Now; mmo1.Text := SimpleSQL.ToString; //output:Params is empty //{"DBConfigID":1234,"Sql":"SELECT * FROM TABLE WHERE ID='My //ID'","Args":"$Name='1313';$VALUE=DATEEW","Params":[]}} SimpleSQL2.FromJson(mmo1.Text); ShowMessage(SimpleSQL2.Sql); end;
Original issue reported on code.google.com by GreenSai...@gmail.com on 17 Dec 2013 at 1:43
GreenSai...@gmail.com
Original comment by onryld...@gmail.com on 17 Dec 2013 at 9:45
onryld...@gmail.com
This issue was closed by revision r32.
Original comment by onryld...@gmail.com on 17 Dec 2013 at 10:23
Original issue reported on code.google.com by
GreenSai...@gmail.com
on 17 Dec 2013 at 1:43