0

我在mysql中创建了一个程序

  DELIMITER // 
   create procedure insert_trans_id (IN $Project_Code varchar(100),IN $user_name 
   varchar(100),IN $item_name varchar(100),IN $Unit_Name 
   varchar(100),IN $item_size1 varchar(50),IN $item_qty1 int,IN $l_name varchar(100)
   )
   begin
  //variable declare here
   declare $p_id int;
   declare $user_id int;
   declare $i_id int;
   declare $unit_id int;
   declare $item_size varchar(50);       
   declare $item_qty int;
   declare $loc_id int;
   //setting variables
   set @item_size = ($item_size1);
   set @item_qty  = ($item_qty1);
   set @p_id      = (SELECT `id` FROM `project_master` WHERE `Project_Code` `enter code here`= $Project_Code) ;
   set @user_id   = ( SELECT  `u_id` FROM `user` WHERE `user_name` = $user_name);
   set @i_id      =(SELECT `id` FROM `item_master` WHERE `item_name` = $item_name);
   set @unit_id   = (SELECT `id` FROM `unit_mstr` WHERE `Unit_Name` = $Unit_Name);
   set @loc_id    = (SELECT `id` FROM `location_mstr` WHERE `l_name` = $l_name);
   PREPARE STMT FROM 
 // insert statement 
"INSERT INTO `project_transaction_header`(`project_id`, `u_id`, `item_Id`,`unit_id`,`Size`, `Qty`, `location_id`, `Created_On`, `Created_By`,`Modified_on`, `Modified_By`)VALUES(p_id,user_id,i_id,$unit_id,item_size,item_qty,loc_id,'system',now(),'system',now() )";

EXECUTE STMT USING @p_id,@user_id,@i_id,@$unit_id,@item_size,@item_qty,@loc_id;
END  

它在 mysql phpmyadmin 中工作正常,但我现在不知道如何在 php 中调用相同的过程,如果可能需要示例,请帮助我

4

1 回答 1

0

您可以使用调用程序call insert_trans_id(parameter1,parameter2)

您可以阅读php手册

要获取 sp 的结果,请阅读上面链接中的示例 #3

于 2013-08-24T20:18:56.823 回答