![]() |
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! |
AW: MySQL via PHP-Tunnel (über eigene libmysql.dll)
Zitat:
Delphi-Quellcode:
to be Pascal or SQL? It is just a string and can contain anything you like and will not be handled by Pascal or SQL. It is just a value
'AA:=1234; bbA'
|
AW: MySQL via PHP-Tunnel (über eigene libmysql.dll)
Ja, stimmt schon.. Nicht gut hingeschaut..
Indeed.. the whole part in quotes is inserted in a field in the database so the Pascal ":=" does not matter nor affect anything. |
AW: MySQL via PHP-Tunnel (über eigene libmysql.dll)
Just did some tests and still got the error
Code:
Still have error on the bottom line.
DROP TABLE IF EXISTS nodes;
CREATE TABLE nodes ( node_id int, parent_id int, bez TEXT, CONSTRAINT PK_nodes PRIMARY KEY (node_id), CONSTRAINT FK_nodes_parent FOREIGN KEY (parent_id) REFERENCES nodes (node_id) ) ENGINE=InnoDB; INSERT INTO nodes VALUES (1, NULL, 'A'); INSERT INTO nodes VALUES (2, 1, 'AA'); INSERT INTO nodes VALUES (3, NULL, 'B'); INSERT INTO nodes VALUES (4, 2, "AA=1234; bbA"); So not everything enclosed in quotes is passed as a string? :oops: Tom |
AW: MySQL via PHP-Tunnel (über eigene libmysql.dll)
Hello Tom,
MySQL will not accept double quotes I guess. The double quotes are only valid from within Delphi. Your SQL statement should work if you quote the string in the last line just like the others. |
AW: MySQL via PHP-Tunnel (über eigene libmysql.dll)
Hi,
Single quotes is how I had it before. Still with the error. Maybe it has something to do with the transfer of data between zeos and the tunnel php file. Tom |
AW: MySQL via PHP-Tunnel (über eigene libmysql.dll)
I executed this in Heidisql without errors:
DROP TABLE IF EXISTS nodes; CREATE TABLE nodes ( node_id int, parent_id int, bez TEXT, CONSTRAINT PK_nodes PRIMARY KEY (node_id), CONSTRAINT FK_nodes_parent FOREIGN KEY (parent_id) REFERENCES nodes (node_id) ) ENGINE=InnoDB; INSERT INTO nodes VALUES (1, NULL, 'A'); INSERT INTO nodes VALUES (2, 1, 'AA'); INSERT INTO nodes VALUES (3, NULL, 'B'); INSERT INTO nodes VALUES (4, 2, 'AA=1234; bbA'); Maybe very stupid question but if the sql I post does not work for you, what happens if you replace the ";"? That could very well be a delimiter in the PHP tunnel.. |
AW: MySQL via PHP-Tunnel (über eigene libmysql.dll)
I am using an sql tunnel demo from the 1st post.
I just need a way to connect to a mysql database using tunneling. I have not done a check but is Heidisql a sql tunnel? I am using Delphi 7 |
AW: MySQL via PHP-Tunnel (über eigene libmysql.dll)
HeidiSql is a tool like phpMyadmin.
I have a few general suggestions: first is to replace the ";" with some different character. If that works, at least you know what the issue is. A quick work around: if you use stringreplace to replace ";" when posting and another stringreplace when retrieving the data, your problem should be worked around. |
AW: MySQL via PHP-Tunnel (über eigene libmysql.dll)
Thanks, yes I think I will test various characters that I can set on the way to the database and reset on the way out.
Tom |
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:21 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