通过wordpress插件创建MySQL功能

时间:2015-11-27 18:17:57

标签: mysql wordpress

我想在用户安装Wordpress插件时在用户的数据库中创建一个MySQL函数。

我已尝试过此代码:

$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
"
);

但它不起作用,不会创建该功能。有没有其他方法可以从Wordpress插件插入此功能?

0 个答案:

没有答案