473,387 Members | 1,497 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Trigger mit PHP-Script: DELIMITER-Problem

Hallo NG,

ich versuche gerade ein PHP-Script zu bauen, das einen Trigger in einer
MySQL-Datenbank erstellt.

Doch leider funktioniert das nicht und ich habe auch über google keine
Hinweise gefunden. Ich vermute, dass es am Delimiter liegt.

Der Code, der per PHP abgeschickt wird:

DELIMITER |
CREATE TRIGGER ext4cAnbieter_del AFTER DELETE ON anbieter
FOR EACH ROW BEGIN
DELETE FROM ext4cSupportform WHERE anbieter = OLD.anbieter;
END;
|
DELIMITER ;
Die Syntax ist laut MySQL-Doku [1] korrekt. Im phpMyAdmin wird der Code
(ohne die DELIMITER-Statements, aber mit Angabe dessen im entsprechenden
Feld) auch angenommen.
Versionen:
PHP 5.2
MySQL 5.0.32
Weiß jemand Rat?

Danke!

Gruß...Sven.

[1] http://dev.mysql.com/doc/refman/5.1/...e-trigger.html
--
http://www.sReuter.net/
http://www.Auskennbert.de/

Aug 20 '08 #1
11 3086
"Jensen Somers" <je****@sig.see.invalidschrieb im Newsbeitrag
news:O9******************************@giganews.com ...
Sven Reuter wrote:

<snip>

This is an English newsgroup, please post your question in English or
in
a newsgroup that targets your language.
Sorry for that. I worked all the day so that I didn't realized that :-(

Here an english version of my post:
I try to write a PHP script that should create a trigger in a MySQL
database.

But it don't work and I don't found hints at google. I assume a problem
with the DELIMITER.

Here's the Code sent by the PHP script:

DELIMITER |
CREATE TRIGGER ext4cAnbieter_del AFTER DELETE ON anbieter
FOR EACH ROW BEGIN
DELETE FROM ext4cSupportform WHERE anbieter = OLD.anbieter;
END;
|
DELIMITER ;

The syntax correct according to MySQL-Doc [1]. In phpMyAdmin the code is
executed well (without DELIMITER statements but with delimiter
expression in the analogical form field).

versions:
PHP 5.2
MySQL 5.0.32
Can anyone help?

Thx!

Bye...Sven.

[1] http://dev.mysql.com/doc/refman/5.1/...e-trigger.html
--
http://www.sReuter.net/
http://www.Auskennbert.de/

Aug 20 '08 #2
Sven Reuter wrote:
Hallo NG,

ich versuche gerade ein PHP-Script zu bauen, das einen Trigger in einer
MySQL-Datenbank erstellt.

Doch leider funktioniert das nicht und ich habe auch über google keine
Hinweise gefunden. Ich vermute, dass es am Delimiter liegt.

Der Code, der per PHP abgeschickt wird:

DELIMITER |
CREATE TRIGGER ext4cAnbieter_del AFTER DELETE ON anbieter
FOR EACH ROW BEGIN
DELETE FROM ext4cSupportform WHERE anbieter = OLD.anbieter;
END;
|
DELIMITER ;
Die Syntax ist laut MySQL-Doku [1] korrekt. Im phpMyAdmin wird der Code
(ohne die DELIMITER-Statements, aber mit Angabe dessen im entsprechenden
Feld) auch angenommen.
Versionen:
PHP 5.2
MySQL 5.0.32
Weiß jemand Rat?

Danke!

Gruß...Sven.

[1] http://dev.mysql.com/doc/refman/5.1/...e-trigger.html
This is an English newsgroup, and it's for PHP - not MySQL. Please ask
in a German MySQL newsgroup.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 20 '08 #3
Jerry Stuckle wrote:
This is an English newsgroup, and it's for PHP - not MySQL. Please
ask in a German MySQL newsgroup.
I wrote my post in an english version again in reply to Jensens post.
I think it's not a problem of MySQL.

--
http://www.sReuter.net/
http://www.Auskennbert.de/

Aug 20 '08 #4
Jerry Stuckle wrote:
Sven Reuter wrote:
>Hallo NG,

ich versuche gerade ein PHP-Script zu bauen, das einen Trigger in
einer MySQL-Datenbank erstellt.

Doch leider funktioniert das nicht und ich habe auch über google keine
Hinweise gefunden. Ich vermute, dass es am Delimiter liegt.

Der Code, der per PHP abgeschickt wird:

DELIMITER |
CREATE TRIGGER ext4cAnbieter_del AFTER DELETE ON anbieter
FOR EACH ROW BEGIN
DELETE FROM ext4cSupportform WHERE anbieter = OLD.anbieter;
END;
|
DELIMITER ;
Die Syntax ist laut MySQL-Doku [1] korrekt. Im phpMyAdmin wird der
Code (ohne die DELIMITER-Statements, aber mit Angabe dessen im
entsprechenden Feld) auch angenommen.
Versionen:
PHP 5.2
MySQL 5.0.32
Weiß jemand Rat?

Danke!

Gruß...Sven.

[1] http://dev.mysql.com/doc/refman/5.1/...e-trigger.html

This is an English newsgroup, and it's for PHP - not MySQL. Please ask
in a German MySQL newsgroup.
Is it?

By golly, and there was me thinking it was a worldwide group.

Aug 20 '08 #5
Sven Reuter wrote:
Jerry Stuckle wrote:
>This is an English newsgroup, and it's for PHP - not MySQL. Please
ask in a German MySQL newsgroup.

I wrote my post in an english version again in reply to Jensens post.
I think it's not a problem of MySQL.
You aren't showing any PHP code, and only asking about SQL code.

comp.databases.mysql is the correct group to be asking in.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 20 '08 #6
Jerry Stuckle wrote:
Sven Reuter wrote:
>Jerry Stuckle wrote:
>>This is an English newsgroup, and it's for PHP - not MySQL. Please
ask in a German MySQL newsgroup.

I wrote my post in an english version again in reply to Jensens post.
I think it's not a problem of MySQL.

You aren't showing any PHP code, and only asking about SQL code.

comp.databases.mysql is the correct group to be asking in.
However the SQL code works, except when embedded into php..

Things to check.

- PHP user has sufficient privileges to access the database in this way:
the phpmyadmin program my not connect to the database as the same user.

- no hidden charcter replacement to the query string is being performed
my the php->mysql shim library.

turn on all error reporting a well.
Aug 20 '08 #7
The Natural Philosopher wrote:
Jerry Stuckle wrote:
>You aren't showing any PHP code, and only asking about SQL code.

comp.databases.mysql is the correct group to be asking in.
However the SQL code works, except when embedded into php..
Yes, that's right. I think I've found a solution for my problem:

Although MySQL requires DELIMITER statements it's not possible to use
them in PHP. I've just sent the statement for the trigger and it worked
(encapsulated in PHP code especially for Jerry ;-) ):

$result = mysql_query('CREATE TRIGGER ext4cAnbieter_del AFTER DELETE ON
anbieter FOR EACH ROW BEGIN DELETE FROM ext4cSupportform WHERE anbieter
= OLD.anbieter; END;');

Bye...Sven.
--
http://www.sReuter.net/
http://www.Auskennbert.de/

Aug 21 '08 #8
Sven Reuter wrote:
The Natural Philosopher wrote:
>Jerry Stuckle wrote:
>>You aren't showing any PHP code, and only asking about SQL code.

comp.databases.mysql is the correct group to be asking in.
However the SQL code works, except when embedded into php..

Yes, that's right. I think I've found a solution for my problem:

Although MySQL requires DELIMITER statements it's not possible to use
them in PHP. I've just sent the statement for the trigger and it worked
(encapsulated in PHP code especially for Jerry ;-) ):
`Be kind to Jerry. He's really past it these days..
$result = mysql_query('CREATE TRIGGER ext4cAnbieter_del AFTER DELETE ON
anbieter FOR EACH ROW BEGIN DELETE FROM ext4cSupportform WHERE anbieter
= OLD.anbieter; END;');
Ee Bai Gum kad, that were a strangling of t'English language.
Bye...Sven.
Aug 21 '08 #9
Sven Reuter wrote:
The Natural Philosopher wrote:
>Jerry Stuckle wrote:
>>You aren't showing any PHP code, and only asking about SQL code.

comp.databases.mysql is the correct group to be asking in.
However the SQL code works, except when embedded into php..

Yes, that's right. I think I've found a solution for my problem:

Although MySQL requires DELIMITER statements it's not possible to use
them in PHP. I've just sent the statement for the trigger and it worked
(encapsulated in PHP code especially for Jerry ;-) ):

$result = mysql_query('CREATE TRIGGER ext4cAnbieter_del AFTER DELETE ON
anbieter FOR EACH ROW BEGIN DELETE FROM ext4cSupportform WHERE anbieter
= OLD.anbieter; END;');

Bye...Sven.
Which is the answer you would have gotten very quickly had you asked in
the correct newsgroup.

This isn't a PHP issue - it's true when you create a trigger using ANY
language APIs. That includes C, Java and any other supported language,
not just PHP.

Here's a hint. PHP knows absolutely NOTHING about CREATE TRIGGER or
similar SQL statements. They're just strings to PHP - which are passed
on to MySQL for processing.

So maybe next time you'll ask in the correct newsgroup - and get an
answer.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 21 '08 #10
Jerry Stuckle wrote:
Sven Reuter wrote:
>The Natural Philosopher wrote:
>>Jerry Stuckle wrote:
You aren't showing any PHP code, and only asking about SQL code.

comp.databases.mysql is the correct group to be asking in.

However the SQL code works, except when embedded into php..

Yes, that's right. I think I've found a solution for my problem:

Although MySQL requires DELIMITER statements it's not possible to use
them in PHP. I've just sent the statement for the trigger and it
worked (encapsulated in PHP code especially for Jerry ;-) ):

$result = mysql_query('CREATE TRIGGER ext4cAnbieter_del AFTER DELETE
ON anbieter FOR EACH ROW BEGIN DELETE FROM ext4cSupportform WHERE
anbieter = OLD.anbieter; END;');

Bye...Sven.

Which is the answer you would have gotten very quickly had you asked in
the correct newsgroup.

This isn't a PHP issue - it's true when you create a trigger using ANY
language APIs. That includes C, Java and any other supported language,
not just PHP.

Here's a hint. PHP knows absolutely NOTHING about CREATE TRIGGER or
similar SQL statements. They're just strings to PHP - which are passed
on to MySQL for processing.

So maybe next time you'll ask in the correct newsgroup - and get an answer.
What part of 'bye' do you not understand?

Oh: comp.lang.english-for-dummies is over there ->
Aug 21 '08 #11
Message-ID: <12***************@proxy00.news.clara.netfrom The Natural
Philosopher contained the following:
>This is an English newsgroup, and it's for PHP - not MySQL. Please ask
in a German MySQL newsgroup.
Is it?

By golly, and there was me thinking it was a worldwide group.
It's an English language group, propagated worldwide.

--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
http://slipperyhill.co.uk - http://4theweb.co.uk
Aug 26 '08 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Hanjo Grüßner | last post by:
Hello, I'm not shure wether it's OT or not. I want to use an eMail as a trigger to start a program. E.g. an eMail-Group: any group-member sends an eMail to a group-e-adress an the Mail is...
2
by: kevin jin | last post by:
Hi, I did read Andrew's article about SQL Server trigger. After a 'Insert' trigger is fired,is there any way we can modify newly added data in virtual 'Insert' table before put them to the...
6
by: Scott CM | last post by:
I have a multi-part question regarding trigger performance. First of all, is there performance gain from issuing the following within a trigger: SELECT PrimaryKeyColumn FROM INSERTED opposed...
0
by: JohnO | last post by:
Thanks to Serge and MarkB for recent tips and suggestions. Ive rolled together a few stored procedures to assist with creating audit triggers automagically. Hope someone finds this as useful as...
2
by: Karl O. Pinc | last post by:
I'm sure I saw something like this on the postgresql web site but the the search function is down in the documentation area. I'm unable to pass a function arguments in a CREATE TRIGGER...
3
by: Justin Clift | last post by:
Hi all, I'm creating a centralised table to keep a log of changes in other tables. In thinking about the PL/pgSQL trigger to write and attach to the monitored tables (probably a row level...
5
by: Mike Nolan | last post by:
I have a before insert trigger that updates a value in another table. It appears that I cannot depend upon that update having taken place in an after insert trigger on the first table. (The one...
9
by: Ots | last post by:
I'm using SQL 2000, which is integrated with a VB.NET 2003 app. I have an Audit trigger that logs changes to tables. I want to apply this trigger to many different tables. It's the same trigger,...
0
by: lalala | last post by:
hi ppl... i am totally new to this stuff and i need to create a trigger before an update operation is occured when it matched the date in the database and i got a sample of trigger from the...
2
by: watusiboy | last post by:
is it possible to trigger a java class stored in my local server through php? thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.