I would like to create a MySQL function in the user's database when they install my Wordpress plugin.
I've tried this code:
$wpdb->query(
"
DELIMITER $$
CREATE FUNCTION `myfunc`(t TEXT CHARSET utf8) RETURNS TEXT CHARSET utf8
BEGIN
SET t = REPLACE(t, 'ą', 'a');
SET t = REPLACE(t, 'Ą', 'A');
SET t = REPLACE(t, 'ć', 'c');
SET t = REPLACE(t, 'Ć', 'C');
SET t = REPLACE(t, 'ę', 'e');
SET t = REPLACE(t, 'Ę', 'E');
SET t = REPLACE(t, 'ł', 'l');
SET t = REPLACE(t, 'Ł', 'L');
SET t = REPLACE(t, 'ń', 'n');
SET t = REPLACE(t, 'Ń', 'N');
SET t = REPLACE(t, 'ó', 'o');
SET t = REPLACE(t, 'Ó', 'O');
SET t = REPLACE(t, 'ś', 's');
SET t = REPLACE(t, 'Ś', 'S');
SET t = REPLACE(t, 'ż', 'z');
SET t = REPLACE(t, 'Ż', 'Z');
SET t = REPLACE(t, 'ź', 'z');
SET t = REPLACE(t, 'Ź', 'Z');
return t;
END
"
);
but it doesn't work, the function is not created. Is there any other way to insert this function from a Wordpress plugin?
CREATE_ROUTINEprivileges?DELIMITERstatement? This question had similar problems, but went unanswered. TheDELIMITERstatement is used on the command line but shouldn't be necessary when sending things from PHP.