Hi,
I am using MySQL, PHP and PDO to insert a support ticket. Inserting works fine but I want to get the ticket_id after insertions using OUT from the stored procedure. Can you please help.
here is my stored procedure followed by my PDO code for INSERT.
CREATE DEFINER=`jassimdb`@`%.%` PROCEDURE `sp_add_new_ticket`(IN param_ticket_name varchar(255), IN param_ticket_email varchar(255), IN param_ticket_subject varchar(255), IN param_ticket_message text, OUT param_record_identity int)
BEGIN
INSERT INTO support_tickets (ticket_guid, ticket_name, ticket_email, ticket_subject) VALUES (UUID(), param_ticket_name, param_ticket_email, param_ticket_subject);
SET param_record_identity = LAST_INSERT_ID();
INSERT INTO support_ticket_messages (ticket_id, support_ticket_message) VALUES (LAST_INSERT_ID(), param_ticket_message);
END
$mysql_query = $mysql_connection->prepare("CALL sp_add_new_ticket(:param_ticket_name, :param_ticket_email, :param_ticket_subject, :param_ticket_message)");
$mysql_query->bindParam(':param_ticket_name', $ticket_name, PDO::PARAM_STR);
$mysql_query->bindParam(':param_ticket_email', $ticket_email, PDO::PARAM_STR);
$mysql_query->bindParam(':param_ticket_subject', $ticket_subject, PDO::PARAM_STR);
$mysql_query->bindParam(':param_ticket_message', $ticket_message, PDO::PARAM_STR);
$mysql_query->execute();
Thanks,
Jassim