function TAdressen.Adresse(Where, Tables:
String): AdressenArr;
var
query:
String;
_myRes: PMySql_Res;
_myRow: PMySql_Row;
Items: Integer;
i: Integer;
Cols: Integer;
begin
if Tables <> '
'
then Tables := '
, ' + Tables;
query := '
SELECT ' +
{0} '
Adressen.AdressenID AS id, ' +
{1} '
t2.Bereich AS Bereich, ' +
{2} '
Adressen.Name AS Name, ' +
{3} '
Adressen.Zusatz AS Zusatz, ' +
{4} '
CONCAT(t1.Strasse," ",t1.Hnr) AS StrasseNr, ' +
{5} '
t1.Plz AS Plz, ' +
{6} '
t1.Ort AS Ort, ' +
{7} '
Adressen.Telefon AS Telefon, ' +
{8} '
Adressen.Fax AS Fax, ' +
{9} '
Adressen.eMail1 AS eMail1, ' +
{10} '
Adressen.Internet AS Internet, ' +
{11} '
t3.Bundesland AS Bundesland, ' +
{12} '
t4.Land AS Land, ' +
{13} '
t1.Strasse AS Strasse, ' +
{14} '
t1.Hnr AS Hnr, ' +
{15} '
t1.Postfach AS Postfach, ' +
{16} '
t1.Postfach_Plz AS Postfach_Plz, ' +
{17} '
t1.Postfach_Ort AS Postfach_Ort, ' +
{18} '
Adressen.eMail2 AS eMail2, ' +
{19} '
t5.Inhalt AS Notizen, ' +
{20} '
t6.Inhalt AS Informationen, ' +
{21} '
Adressen.OnlineVeroeffentlichung AS OE, ' +
{22} '
Adressen.BereichZuweisung AS Zuweisung ' +
'
FROM Adressen ' +
Tables + '
' +
'
INNER JOIN Adresse AS t1 ON Adressen.Adresse = t1.AdresseID ' +
'
INNER JOIN Bereiche AS t2 ON t2.BereichID = Adressen.Bereich ' +
'
LEFT JOIN Bundeslaender AS t3 ON t3.BundeslandID = t1.Bundesland ' +
'
LEFT JOIN Laender AS t4 ON t4.LaenderID = t1.Land ' +
'
LEFT JOIN Texte AS t5 ON t5.TexteID = Adressen.Informationen ' +
'
LEFT JOIN Texte AS t6 ON t6.TexteID = Adressen.Notizen ' +
Where;
Cols := 23;
mysql_real_query(_myCon, PChar(
query), Length(
query));
_myRes := mysql_store_result(_myCon);
if _myRes <>
nil then
begin
Items := mysql_num_rows(_myRes);
SetLength(Result, 1, Cols);
if Items >= 0
then
begin
SetLength(Result, Items, Cols);
for i := 0
to Items - 1
do
begin
_myRow := mysql_fetch_row(_myRes);
Result[i,0] := _myRow[0];
Result[i,1] := _myRow[1];
Result[i,2] := _myRow[2];
Result[i,3] := _myRow[3];
Result[i,4] := _myRow[4];
Result[i,5] := _myRow[5];
Result[i,6] := _myRow[6];
Result[i,9] := Telefonnummern('
Telefon', _myRow[0]);
Result[i,10] := Telefonnummern('
Fax', _myRow[0]);
Result[i,11] := _myRow[9];
Result[i,12] := _myRow[10];
Result[i,7] := _myRow[11];
Result[i,8] := _myRow[12];
Result[i,13] := _myRow[13];
Result[i,14] := _myRow[14];
Result[i,15] := _myRow[15];
Result[i,16] := _myRow[16];
Result[i,17] := _myRow[17];
Result[i,18] := _myRow[18];
Result[i,19] := _myRow[19];
Result[i,20] := _myRow[20];
Result[i,21] := _myRow[21];
Result[i,22] := _myRow[22];
end;
end
else
begin
SetLength(Result, 0, Cols);
end;
end;