http://zhidao.baidu.com/link?url=DmmuiPFlAi1XzJdOyqxI980MeuV3iGUM9TdM7zQVkkjt9sMJF92zXKu7YvElrp8-aXHtZ5rp1tMq4yoNrMu_7a
-
实现原理
-
首先,需要知道怎么写mysql存储过程,了解mysq存储过程语言,
-
其次,使用mysql工具创建存储过程。
-
最后,通过mysql_query()函数执行mysql变量的设置和mysql存储过程及返回值。
-
具体代码如下:
-
mysql存储过程代码
create
procedure
pro_name(user_id
int
)
begin
.........
end
|
2. PHP代码
$host
=
"localhost"
;
$user
=
"root"
;
$password
=
"232412"
;
$db
=
"user_db"
;
$dblink
= mysql_connect(
$host
,
$user
,
$password
)
or
die
(
"can't connect to mysql"
);
mysql_select_db(
$db
,
$dblink
)
or
die
(
"can't select user_db"
);
$user_id
= 1;
$res
= mysql_query(
"set @a=$user_id"
,
$dblink
);
$res
= mysql_query(
"call pro_name(@a)"
,
$dblink
);