PHP,用PDO调用MYSQL存储过程的问题。

WBOY
Release: 2016-06-23 13:52:40
Original
1138 people have browsed it

MYSQL里有个存储过程,比如有2个IN,3个OUT。
PHP里用PDO的方式调用这个存储过程,怎么将3个返回值存到一个数组中。谢谢。

$DSN = "$DBMS:host=$HOST;dbname=$DBName";
$pdo = new PDO($DSN,$UserName,$PassWord);
$pdo -> query("set names uft8");
$_query="call testproreg('a','b')";
$result=$pdo->prepare($_query);
$result->execute();
接下来应该怎么办呢?谢谢大家了!


回复讨论(解决方案)

http://php.net/manual/zh/pdostatement.bindparam.php #3

班主说的那个不好用的.手册里面的那个范例不好使,我测试过了,连存储过程都没调用成功啊.

<?php/* 使用 INOUT 参数调用一个存储过程 */$colour = 'red';$sth = $dbh->prepare('CALL puree_fruit(?)');$sth->bindParam(1, $colour, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);$sth->execute();print("After pureeing fruit, the colour is: $colour");?> 
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template