嗯,我有我编写的MySQL存储过程,如果我在phpMyAdmin中运行以下内容,则返回正确:
SELECT game_name,urlfriendly(game_name) AS game_name2 FROM games
但是,如果我尝试运行以下代码,我会收到错误“警告:在#filepath.php中为foreach()提供的无效参数#”
foreach ($this->database->query("SELECT game_name,urlfriendly(game_name) AS game_name2 FROM games") as $games)
{
echo $games["game_name"] . " " . $games["game_name2"];
}
但是,如果我运行它,一切都很顺利:
foreach ($this->database->query("SELECT game_name FROM games") as $games)
{
echo $games["game_name"];
}
意味着存储过程不会返回PHP。
有什么想法吗?
编辑这是存储过程(但我怀疑这是问题,因为phpMyAdmin正在从中拉回价值就好了)
DELIMITER //
DROP FUNCTION urlfriendly
//
CREATE FUNCTION urlfriendly (unsafe TEXT) RETURNS TEXT
DETERMINISTIC
BEGIN
DECLARE safe TEXT;
SET safe = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(LOWER(unsafe),' ','-'),'&','and'),'`',''),'~',''),'!',''),'@',''),'#',''),'$',''),'%',''),'^',''),'*',''),'(',''),')',''),'_',''),'+',''),'=',''),'[',''),'{',''),']',''),'}',''),'|',''),'\\',''),"'",""),'"',''),':',''),';',''),'<',''),',',''),'>',''),'.',''),'/',''),'?','');
RETURN safe;
END
//
EDIT2 以下是MySQL返回的错误
execute command denied to user 'username'@'localhost' for routine 'databasename.urlfriendly' )
答案 0 :(得分:3)