我在 mysql 中有一个带有输出参数的存储过程,我需要将结果发送到我的 php 中,该 php 使用了 codeigniter
注册模式
public function registerUser($data){
$sql = "call register_new_user('" . $data['uemail'] . "','" . $data['fname'] . "','".$data['lname'] . "','" . $data['pword']."',
'" . $data['states'] . "',".$data['chargifyId'].");";
if ($query = $this->db->query($sql)) {
return $this->db->query("Select @last_id");
} else {
return false;
}
}
这是存储过程
CREATE DEFINER=`root`@`localhost` PROCEDURE `register_new_user`(IN `uemail` VARCHAR(100), IN `fname` VARCHAR(45),
IN `lname` VARCHAR(45), IN `pword` VARCHAR(100), IN `states` VARCHAR(20), IN `chargifyid` INT, OUT `last_id` INT)
NO SQL
BEGIN
if not exists (SELECT * from gi_user where
(gi_user_email = uemail)) THEN
INSERT INTO gi_user(gi_user_email, gi_user_fname,
gi_user_lname, gi_user_password,gi_user_status,
gi_account_id, chargifyId)
VALUES (uemail,fname,lname,pword,states,1,chargifyid);
SET last_id = LAST_INSERT_ID( ) ;
END IF;
END