SQL语句, 我想在PHP中做一个收藏按钮 ,点击后从数据库表中调取用户和商店ID到新的表中
1个回答
展开全部
你可以先在数据库中写一个存储过程Add_Favorite,然后在收藏按钮添中调用加这个存储过程就可以了。
Oracle Procedure Sample:
create or replace procedure Add_Favorite (P_UserName in Varchar2, P_ShopName in Varchar2) As
BEGIN
Insert into Table_Name values(P_UserName, P_ShopName) ;
EXCEPTION
WHEN others THEN
rollback;
END Add_Favorite;
PHP 调用 Add_Favorite:
$sql_sp = "BEGIN Add_Favorite(:UserName, :ShopName); END;";
$stmt = OCIParse($conn, $sql_sp);
OCIBindByName($stmt, ":UserName", $id, 16);
OCIBindByName($stmt, ":ShopName", $name, 30);
OCIExecute($stmt);
Oracle Procedure Sample:
create or replace procedure Add_Favorite (P_UserName in Varchar2, P_ShopName in Varchar2) As
BEGIN
Insert into Table_Name values(P_UserName, P_ShopName) ;
EXCEPTION
WHEN others THEN
rollback;
END Add_Favorite;
PHP 调用 Add_Favorite:
$sql_sp = "BEGIN Add_Favorite(:UserName, :ShopName); END;";
$stmt = OCIParse($conn, $sql_sp);
OCIBindByName($stmt, ":UserName", $id, 16);
OCIBindByName($stmt, ":ShopName", $name, 30);
OCIExecute($stmt);
追问
谢谢
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询