![]() |
AW: MySQL via PHP-Tunnel (über eigene libmysql.dll)
Datenbank-Zeichensatz
Hier hilft das Einstellen einer anderen Codepage, auch über PHPMyAdmin.
Code:
Mehrbenutzerfähigkeit für Internetanwendungen
SET SESSION CHARACTER_SET_RESULTS =latin1;
SET SESSION CHARACTER_SET_CLIENT =latin1; 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:
Man kann dann eine Log-Tabelle anlegen um Eintragungen zu protokolieren.
SELECT SUBSTRING_INDEX(USER(),'@',1);
Code:
Hier kann man mit einem Insert-Statement aktuellen USER und HOST eintragen. TIMESTAMP hat dabei die aktuelle Datum/Zeit-Kombination.
CREATE TABLE app_log
( t TIMESTAMP, user CHAR(16), host CHAR(60) );
Code:
Oder man baut einen Trigger der den aktuellen User im Insert mit aufnimmt:
INSERT INTO app_log
SET user = SUBSTRING_INDEX(USER( ),'@',1), host = SUBSTRING_INDEX(USER( ),'@',-1);
Code:
Jetzt kann verhindert werden, dass ein anderer User den eigenen Datensatz löscht. Das geht über einen Before-Delete Trigger:
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();
Code:
Man kann auch noch eine Audit/Log Tabelle führen und sehen wer gelöscht hat:
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;
Code:
Ziel der Geschichte ist eine Tabelle mehrbenutzerfähig im Internet verwalten zu können.
-- 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; Etwas Feinabstimmung ist hier wohl noch drin. Grüße in die Runde |
AW: MySQL via PHP-Tunnel (über eigene libmysql.dll)
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 |
AW: MySQL via PHP-Tunnel (über eigene libmysql.dll)
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 |
AW: MySQL via PHP-Tunnel (über eigene libmysql.dll)
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 |
AW: MySQL via PHP-Tunnel (über eigene libmysql.dll)
Hi Tom,
please show us the exact and real code enclosed in
Code:
tags.
[DELPHI][/DELPHI]
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; |
AW: MySQL via PHP-Tunnel (über eigene libmysql.dll)
Sorry for that.
Yes that is the code. It seems as though the error is the ":" or "=" or the ";" which causes the error. Tom |
AW: MySQL via PHP-Tunnel (über eigene libmysql.dll)
Syntax Highlight will tell you what is wrong
wrong code
Delphi-Quellcode:
right code
var
stmt : string begin stmt := 'INSERT INTO nodes VALUES (4, 2, 'AA:=1234; bbA');'; end;
Delphi-Quellcode:
You simply have to double the quotes inside the string
var
stmt : string begin stmt := 'INSERT INTO nodes VALUES (4, 2, ''AA:=1234; bbA'');'; end; |
AW: MySQL via PHP-Tunnel (über eigene libmysql.dll)
Thanks, will do.
I was using the Delphi quotedstr function. Will change to double quotes. Tom |
AW: MySQL via PHP-Tunnel (über eigene libmysql.dll)
Zitat:
|
AW: MySQL via PHP-Tunnel (über eigene libmysql.dll)
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! |
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:32 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz