例如,假设我要执行以下查询:
SELECT * FROM posts;
因此,我写了以下内容:
CREATE DEFINER=`root`@`localhost` PROCEDURE `get_posts`(IN `zip` INT)
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
SELECT * FROM posts WHERE posts.zip = zip;
END
以下更改是我唯一要做的更改:
mysql_query("SELECT * FROM posts");
// to
mysql_query("CALL get_posts");
...然后我可以获取行等?