AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Projekte MySQL via PHP-Tunnel (über eigene libmysql.dll)
Thema durchsuchen
Ansicht
Themen-Optionen

MySQL via PHP-Tunnel (über eigene libmysql.dll)

Ein Thema von omata · begonnen am 22. Feb 2010 · letzter Beitrag vom 25. Mai 2015
Antwort Antwort
Seite 9 von 10   « Erste     789 10      
omata
Registriert seit: 26. Aug 2004
Dieses Projekt ermöglicht den Zugriff auf eine MySQL-Datenbank über ein PHP-Skript.

Dabei werden folgende Punkte untersützt:
  • Lesender Zugriff
  • Schreibender Zugriff
  • Transactionsteuerung
  • Auslesen von Systeminformationen
  • Funktioniert auch im Designmodus von Delphi
  • Stellt den Zugriff über TDataset zur Verfügung, damit können alle normalen Datenbankkomponenten verwendet werden
Miniaturansicht angehängter Grafiken
phptunnel.png  
Angehängte Dateien
Dateityp: zip SQLTunnel.zip (1,41 MB, 301x aufgerufen)
Dateityp: rar SQLTunnel_src.rar (4,48 MB, 217x aufgerufen)

Geändert von omata (14. Aug 2011 um 19:27 Uhr)
 
Benutzerbild von mschaefer
mschaefer

 
Delphi XE3 Enterprise
 
#81
  Alt 14. Aug 2011, 15:45
Datenbank-Zeichensatz
Hier hilft das Einstellen einer anderen Codepage, auch über PHPMyAdmin.

Code:
SET SESSION CHARACTER_SET_RESULTS =latin1;
SET SESSION CHARACTER_SET_CLIENT =latin1;
Mehrbenutzerfähigkeit für Internetanwendungen
Hier gib es de Möglichkeit den aktuell angemeldeten Benutzer in die Tabelle einzutragen. Zum Beispiel um späte eine Logik zu entwickeln, die Löschvorgänge auf selbst angelegte Datensätze beschränkt. MySQL bietet hier die USER()-Funktion an: SELECT CURRENT_USER();.

Um den aktuellen Benutzer abzufragen kann man folgende Abfrage schicken:
Code:
SELECT SUBSTRING_INDEX(USER(),'@',1);
Man kann dann eine Log-Tabelle anlegen um Eintragungen zu protokolieren.
Code:
CREATE TABLE app_log
(
    t      TIMESTAMP,
    user   CHAR(16),
    host   CHAR(60)
);
Hier kann man mit einem Insert-Statement aktuellen USER und HOST eintragen. TIMESTAMP hat dabei die aktuelle Datum/Zeit-Kombination.
Code:
INSERT INTO app_log
    SET user = SUBSTRING_INDEX(USER( ),'@',1),
        host = SUBSTRING_INDEX(USER( ),'@',-1);
Oder man baut einen Trigger der den aktuellen User im Insert mit aufnimmt:
Code:
create database dbtest;
use dbtest;
grant all privileges on dbtest.* to 'testuser'@'localhost';
create table test (creator varchar(30), modificator varchar(30), text varchar(100));
create trigger ins_test before insert on test for each row set new.modificator=current_user();
Jetzt kann verhindert werden, dass ein anderer User den eigenen Datensatz löscht. Das geht über einen Before-Delete Trigger:
Code:
DROP TRIGGER IF EXISTS users_anon;
delimiter |
CREATE TRIGGER users_anon BEFORE DELETE ON users
  FOR EACH ROW BEGIN
    -- Prevent deletion
    IF (OLD.modificator <> user() ) THEN
      -- This raises an exception and prevents deletion
      INSERT INTO users VALUES (OLD);
    END IF;
  END;
Man kann auch noch eine Audit/Log Tabelle führen und sehen wer gelöscht hat:
Code:
 -- before delete trigger
     CREATE OR REPLACE TRIGGER employee_before_delete
      BEFORE DELETE
          ON MyTable
          FOR EACH ROW
      DECLARE
          v_username varchar2(10);
      BEGIN
          -- Find username of person performing the DELETE on the table
          SELECT user INTO v_username
          FROM dual;
          -- Insert record into audit table
          INSERT INTO table_audit (id,     delete_date,deleted_by )
                              VALUES (:old.id, sysdate, v_username );
     END;
Ziel der Geschichte ist eine Tabelle mehrbenutzerfähig im Internet verwalten zu können.
Etwas Feinabstimmung ist hier wohl noch drin.

Grüße in die Runde
Martin Schaefer

Geändert von mschaefer (15. Aug 2011 um 10:52 Uhr) Grund: Ergänzung
  Mit Zitat antworten Zitat
janvanbogget

 
Delphi 2007 Professional
 
#82
  Alt 12. Mär 2013, 10:12
Ich habe ein Problem: wenn ich den umzug Delphi antrag gestellt, um einen PC, wo Delphi nicht installiert ist, dann ist es nicht mehr zu existieren. Ich habe aber den zugehörigen dll's dbxmys.dll und libmysql.dll in das arbeitsverzeichnis und im System32 ordner geschrieben.

Wenn ich zu diesem Host verbinden möchten bekomme ich eine Fehlermeldung: DBX Error: Warning

Wenn die anwendung auf dem entwickler-Station funktioniert und auf einem PC ohne Delphi nicht, dann nehme ich an, dass es noch einige notwendigkeit, auf dem PC, wo kein delphi installiert ist, aber was? Kann mir jemand ein tipp / hint geben ?

ps: ich kann nicht Deutsch schreiben (Hilfe von Google Übersetzer)


Vielen Dank für jede Hilfe
Jan

Geändert von janvanbogget (12. Mär 2013 um 11:10 Uhr)
  Mit Zitat antworten Zitat
janvanbogget

 
Delphi 2007 Professional
 
#83
  Alt 15. Nov 2013, 07:30
Dear,


I have tested your application.

I have compiled your source code with Delphi 2007 Win32, and it works great !

But your dll libmysql.dll is a 32-bits dll, and i work With Lazarus 64 bit ..
So my application can not work with the 32-bits dll.

My question is this : You have make a 64-bits dll ? If you have make this, is it possible that i can use this dll ?

Best Greetings, Jan Van Bogget ( Belgium ) vanbogget.jan@gmail.com
Jan
  Mit Zitat antworten Zitat
sippytom
 
#84
  Alt 25. Mai 2015, 05:59
Hi,
I am English so sorry I cannot ask this question in German.
I have tested your Zeos addition and am very happy.
One problem I have is in inserting some characters into a database.
Here is a demo from your program which will show the error.
INSERT INTO nodes VALUES (4, 2, 'AA:=1234; bbA');

The error occurs around the ":=".
Has this something to do with the way the data is sent to the php file.
If so,is their a way around the error.
Thanks in advance

OR. are their any other sql tunnel routines available.

Tom Duncan
Australia

Geändert von sippytom (25. Mai 2015 um 07:18 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

 
Delphi 10 Seattle Enterprise
 
#85
  Alt 25. Mai 2015, 07:27
Hi Tom,

please show us the exact and real code enclosed in
Code:
[DELPHI][/DELPHI]
tags.
Do not show us look alike code.

I supect, that your code looks something like
Delphi-Quellcode:
var
  stmt : string
begin
  stmt := 'INSERT INTO nodes VALUES (4, 2, 'AA:=1234; bbA');';
end;
  Mit Zitat antworten Zitat
sippytom
 
#86
  Alt 25. Mai 2015, 07:31
Sorry for that.
Yes that is the code.
It seems as though the error is the ":" or "=" or the ";" which causes the error.

Tom
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

 
Delphi 10 Seattle Enterprise
 
#87
  Alt 25. Mai 2015, 08:02
Syntax Highlight will tell you what is wrong

wrong code
Delphi-Quellcode:
var
  stmt : string
begin
  stmt := 'INSERT INTO nodes VALUES (4, 2, 'AA:=1234; bbA');';
end;
right code
Delphi-Quellcode:
var
  stmt : string
begin
  stmt := 'INSERT INTO nodes VALUES (4, 2, ''AA:=1234; bbA'');';
end;
You simply have to double the quotes inside the string
  Mit Zitat antworten Zitat
sippytom
 
#88
  Alt 25. Mai 2015, 08:23
Thanks, will do.
I was using the Delphi quotedstr function.
Will change to double quotes.
Tom
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

 
Delphi 10 Seattle Enterprise
 
#89
  Alt 25. Mai 2015, 09:31
Thanks, will do.
I was using the Delphi quotedstr function.
Will change to double quotes.
Tom
You should change the whole to use parameters in your queries. Just take a google search for that
  Mit Zitat antworten Zitat
teosuper
 
#90
  Alt 25. Mai 2015, 11:04
The answer is not complete. I agree to the quotes but the assignment ":=" is Pascal, not SQL. So you have to change that to "=".

Sorry.. Neither English nor German so I forgot what the ":" is called Good luck!
Teo
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 9 von 10   « Erste     789 10      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:37 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz