这是这个问题的延伸:SO
我想在Wordpress插件中实现@Shadow提供的mysql触发器。查询=触发器为
$sql_trigger = "
drop trigger if exists bi_tbl_B $$
delimiter $$
create trigger bi_tbl_B before insert on tbl_B
for each row begin
DECLARE v_slug as varchar(255);
DECLARE v_url as text;
SELECT url, slug INTO v_url, v_slug FROM tbl_A WHERE id = NEW.id;
NEW.url=v_url;
NEW.slug=v_slug;
end;
$$
delimiter ;
";
mysqli_multi_query($wpdb->dbh,$sql_trigger);
我有几个问题:
1) 此查询是否正确,或者我需要进行更改?
2) 我必须用这个吗
global $wpdb;
或
$mysqli = new mysqli();
$mysqli->connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
3)查询是否安全?