我的问题是,当我尝试通过 php 的 mysql_query 函数执行下面的查询时,它什么也没做(当然除了这个查询之外的所有工作)。如果我把 die(mysql_error()) 放在查询的最后,它只显示白页而不是一个错误。另一方面,如果我尝试直接从 mysql 客户端执行它,则 sql 代码可以工作。我不知道到底出了什么问题。这是sql代码。
-- Instructions:
-- Set the NPC Entry and stats you want it to have below.
SET
@NPC_ENTRY := ".$entry.", -- This is your NPC's Entry
@NPC_HEALTH := ".$health.", -- This is the health value you want your NPC to have.
@NPC_MANA := ".$mana.", -- This is the mana value you want your NPC to have.
@NPC_ARMOR := ".$armor."; -- This is the armor value you want your NPC to have.
-- DO NOT CHANGE ANYTHING BELOW, UNLESS YOU KNOW WHAT YOU ARE DOING.
-- Getting NPC datas:
SET
@NPC_CLASS := (SELECT `unit_class` FROM creature_template WHERE Entry = @NPC_ENTRY),
@NPC_LEVEL := ROUND(((SELECT `minlevel` FROM creature_template WHERE Entry = @NPC_ENTRY)+ (SELECT `maxlevel` FROM creature_template WHERE Entry = @NPC_ENTRY))/2, 0),
@EXP := (SELECT `exp` FROM creature_template WHERE Entry = @NPC_ENTRY);
-- Getting base HP from a HP column defined by exp.
SET
@GET_HP_COL :=
(SELECT CASE @EXP
WHEN 0 THEN (SELECT basehp0 FROM creature_classlevelstats WHERE `level` = @NPC_LEVEL and `class` = @NPC_CLASS)
WHEN 1 THEN (SELECT basehp1 FROM creature_classlevelstats WHERE `level` = @NPC_LEVEL and `class` = @NPC_CLASS)
WHEN 2 THEN (SELECT basehp2 FROM creature_classlevelstats WHERE `level` = @NPC_LEVEL and `class` = @NPC_CLASS)
END),
-- Getting base mana
@GET_MA_COL := (SELECT basemana FROM creature_classlevelstats WHERE `level` = @NPC_LEVEL and `class` = @NPC_CLASS),
-- Getting base armor
@GET_AR_COL := (SELECT basearmor FROM creature_classlevelstats WHERE `level` = @NPC_LEVEL and `class` = @NPC_CLASS);
-- Running the update with all the data collected:
UPDATE creature_template SET Health_mod = (@NPC_HEALTH/@GET_HP_COL), Mana_mod = (@NPC_MANA/@GET_MA_COL), Armor_mod = (@NPC_ARMOR/@GET_AR_COL) WHERE Entry = @NPC_ENTRY;
如果我的帖子有错误,我深表歉意。英语不是我的母语。:(