说我在mysql中有一个存储过程,如下所示
-- ----------------------------
-- Procedure structure for usp_insert_user_basic_info
-- ----------------------------
DROP PROCEDURE IF EXISTS `usp_insert_user_basic_info`;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `usp_insert_user_basic_info`(IN `user_first_name` varchar(200),IN `user_last_name` varchar(200),IN `user_password` text,IN `user_dob` date,IN `user_email` varchar(250))
BEGIN
#Routine body goes here...
INSERT INTO `nuclear`.`user_basic_info` (
`user_email` ,
`user_password` ,
`user_first_name` ,
`user_last_name` ,
`user_dob`,
`user_creation_time`
)
VALUES (
user_email, user_password, user_first_name, user_last_name, user_dob,NOW()
);
SELECT LAST_INSERT_ID() ;
END
;;
DELIMITER ;
桌子
-- ----------------------------
-- Table structure for user_basic_info
-- ----------------------------
DROP TABLE IF EXISTS `user_basic_info`;
CREATE TABLE `user_basic_info` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`user_email` varchar(250) DEFAULT NULL,
`user_password` text,
`user_first_name` varchar(200) DEFAULT NULL,
`user_last_name` varchar(200) DEFAULT NULL,
`user_dob` date DEFAULT NULL,
`user_creation_time` datetime DEFAULT NULL,
PRIMARY KEY (`user_id`),
UNIQUE KEY `user_email` (`user_email`)
) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=latin1;
我可以毫无问题地从 php 调用它
$resultUsp = mysql_query($query) or die("Error: " . mysql_error());
但它只为每个成功的插入返回 1。我想这是说 1 行受影响!
我想让它回来LAST_INSERT_ID
怎么做?顺便说一句,我不想添加任何 OUT 参数。mysql_insert_id 返回 0