 |
| Hints for PHP - developers |  |
 |
 |
PHP developers need some rethinking if they want to use tdbengine:
Tdbengine programs are no parsed HTML - pages, but real CGI-applications which need to create a website themselves. Therefore they can send simple WRITE-instructions directly to the client system or (even better!) use a template (HTML page with placeholders), replace the placeholders and send the resulting page to the client (browser).
That's why it is not necessary to write a program for every new query or action. The tdbengine prefers to have all the functionality - for example a press-release system - in one program.The single functions may be delivered by GET or POST-instructions and are evaluated by a single dispatcher. Thats why the main function in many programs just looks like this:
PROCEDURE Main
VAR command:=GetQueryString('command')
IF command='search' THEN ...
ELSIF command='login' THEN ...
ELSIF command='logout' THEN ...
ELSIF ...
ELSE ... // Startpage
END
ENDPROC
The integrated database works much more directly with the tables than the connection to an external SQL-database. This might look a bit strange to you, maybe even more strange than the Syntax of EASY that resembles Pascal.
Here's a little code fragment which sends a query ($PLZ like "8????") to an address-table and puts out the found records.
VAR db : INTEGER = OpenDB('database/adressen.dat') //Tabelle (zum Lesen) öffnen
VAR nn : INTEGER = FindAndMark(db,'$PLZ LIKE "8????"') // Suchen IF nn=0 THEN //Kein Treffer
CGIWriteLn('Leider nichts gefunden')
ELSE // Die Tabellenzeilen der gefundenen Datensätze sind IN der Markierungsliste
CGIWriteLn(Str(nn)+' Datensätze gefunden.') // Erst einmal eine Meldung
VAR x : INTEGER = FirstMark(db) // An den Anfang der Markierungsliste
WHILE x>0 DO // Die gesamte Markierungsliste durchgehen
ReadRec(db,x) // Zeile holen
CGIWriteLn(GetField(db,'Name')) // Spalten ausgeben
CGIWriteLn(GetField(db,'Strasse'))
...
x:=NextMark(db,x) END
END
The direct-table access is much more performant.
|