Autor |
Beitrag |
OliverN_26
Beiträge: 252
Win7 64-Bit, WinXP SP3
Delphi 7 Enterprise
|
Verfasst: Fr 15.11.13 12:24
Hallo
Wie kann ich ein in PHP existierendes Array so an Delphi übergeben, dass ich nachher in Delphi einfach auf die entsprechenden Werte zugreifen kann?
Ich probier mir da grad nen Wolf und hab mich glaub ich in eine komplett falsche Richtung bewegt.
PHP
PHP-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
| $zaehler = 0; $service = array(); $result = mysql_query("SELECT * FROM sk_schnittstelle_historie ORDER BY umschh_id ASC"); while($felder = mysql_fetch_assoc($result)) { $service[$zaehler]['id'] = $felder['umschh_id']; $service[$zaehler]['aufgabe'] = $felder['umschh_aufgabe']; $service[$zaehler]['kurztext'] = utf8_encode($felder['umschh_text']); $service[$zaehler]['text'] = utf8_encode($felder['umschh_beschreibung']); $zaehler++; } echo json_encode($service); |
DELPHI
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17:
| procedure TForm1.Services_laden; var sl : TStringList; data : Array[0..25] of String; begin sl := TStringlist.Create; sl.Add('Merker=87');
try data := IdHTTP1.Post('http://' + Hostname + '/mds/dp/sql/select.php',sl); showmessage(data[0]); except Exit; end;
sl.Free; end; |
Vielen Dank für jede Hilfe.
lg
Oliver
|
|
baumina
Beiträge: 305
Erhaltene Danke: 61
Win 7
Delphi 10.2 Tokyo Enterprise
|
Verfasst: Fr 15.11.13 12:53
Ich habe das hier gefunden, evtl. hilft dir dieses Beispiel ja:
www.delphipraxis.net...ttp-post-senden.html
|
|
OliverN_26
Beiträge: 252
Win7 64-Bit, WinXP SP3
Delphi 7 Enterprise
|
Verfasst: Fr 15.11.13 12:59
Hallo
Leider nicht, da mir die Übergabe von Variablen klar ist.
Mein Ziel das PHP Array so nach Delphi zu übertragen dass ich die jeweiligen Zeilen/Felder entsprechend anspringen kann .. und genau da ist mein Problem.
Ich weiß wie ich ein Array erstelle/anspreche in PHP und Delphi einzeln. Wie ich Variablen von PHP nach Delphi bekomme weiß ich auch .. nur halt nicht wie das mit einem Array funktionieren soll.
|
|
Lemmy
Beiträge: 792
Erhaltene Danke: 49
Windows 7 / 10; CentOS 7; LinuxMint
Delphi 7-XE10.1, VS 2015
|
Verfasst: Fr 15.11.13 13:01
hi,
da sollte doch JSON das richtige Format sein.... Mit XE5 lässt sich das auch recht schmerzfrei verarbeiten, für andere Versionen gibts auch Implementierungen von Fremdherstellern....
|
|
OliverN_26
Beiträge: 252
Win7 64-Bit, WinXP SP3
Delphi 7 Enterprise
|
Verfasst: Fr 15.11.13 13:04
Ich denke auch dass ich auf PHP Seite nichts mehr ändern muß und JSON der richtige Weg ist.
Wie aber empfange ich den PHP-Request mit Delphi? Ich hab das Gefühl das ist letztendlich immer ein String. Irgendwie muß ich doch nachher die einzelnen Felder anspringen können?
|
|
OliverN_26
Beiträge: 252
Win7 64-Bit, WinXP SP3
Delphi 7 Enterprise
|
Verfasst: Fr 15.11.13 14:22
Nun ja .. ich nutze Delphi 7 Enterprise .. hättest du evt ein Beispiel für einen Fremdanbieter?
|
|
iKilledKenny
Beiträge: 394
Erhaltene Danke: 8
Win XP
D5 Prof, C# Express 2005
|
Verfasst: Fr 15.11.13 16:14
Hier gibts ein OpenSource Projekt, habs noch nicht verwendet, steht aber auf meiner ToDo Liste.
|
|
Martok
Beiträge: 3661
Erhaltene Danke: 604
Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
|
Verfasst: Fr 15.11.13 16:56
Die hier habe ich schon verwendet. Der Code ist innen drin sehr seltsam, aber schnell und von der Benutzung her ganz angenehm.
_________________ "The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
|
|
OliverN_26
Beiträge: 252
Win7 64-Bit, WinXP SP3
Delphi 7 Enterprise
|
Verfasst: Fr 15.11.13 17:08
|
|
OliverN_26
Beiträge: 252
Win7 64-Bit, WinXP SP3
Delphi 7 Enterprise
|
Verfasst: Fr 15.11.13 17:16
JSON Rückgabe sieht übrigens so aus:
Einloggen, um Attachments anzusehen!
|
|
OliverN_26
Beiträge: 252
Win7 64-Bit, WinXP SP3
Delphi 7 Enterprise
|
Verfasst: Fr 15.11.13 17:55
@iKilledKenny:
Mit in den Source geschriebenen Testdaten klappt es .. mit meiner JSON Rückgabe bekomm ich ne Exception 'Ungültige Typenumwandlung'.
Wobei ich denke dass "SuperObject" mehr das wäre wonach ich suche .. grad weils auch um Arrays geht. Scheint einfach ansprechbar zu sein .. wenns denn läuft
Mein Kopf
|
|