DELIMITER $$
USE `test`$$
DROP PROCEDURE IF EXISTS `sp_update_NotifyTrainerStatus_in_notification_table`$$
CREATE DEFINER=`root`@`%` PROCEDURE `sp_update_NotifyTrainerStatus_in_notification_table`(IN email VARCHAR(50), IN id BIGINT)
BEGIN
SELECT @employee_id := `Employee_Id` FROM `employee_profile` WHERE `Email_Id` = email;
UPDATE notification_status_table SET NotifyTrainerStatus=1 WHERE Employee_Id =@employee_id AND Training_Id = id;
END$$
DELIMITER ;
这是我的 mysql 查询,我必须在 id=6 时运行它。我有我的 php 代码,如下所示
if ( $id == 6 ) {
// echo $trainingid;
// echo "Inside id=6";
mysql_query("call update_notify_trainer_in_status_table(" . $trainingid . ")");
$n = count( $to );
// echo "count : ".$n;
// foreach( $to as $values ) {
for( $i = 0; $i < $n; $i++ ) {
// echo $values;
$trainer_mail = $to[$i];
echo $trainer_mail;
//echo $trainingid;
mysql_query("call sp_update_NotifyTrainerStatus_in_notification_table('".$trainer_mail."' , " . $trainingid . ")") or die( mysql_error() );
}
}
我的问题是这个查询对第一个 $trainer_mail 运行良好,而对第二个 $trainer_mail 没有运行。有什么建议么。提前致谢。