调用存储过程时内存不足

时间:2016-01-25 10:36:32

标签: php pdo odbc

我从将数据写入数据库的存储过程中重新获取数据时遇到了麻烦。正确建立连接,因为其他过程,即只返回数据而不写入的过程(如“call rec.getProducts()”),效果很好。每当我执行以下代码时,我都会收到错误:

Out of memory (allocated 262144) (tried to allocate -3 bytes)

程序声明如下:

OUT MSG VARCHAR(300),       
OUT STATE CHAR(5),
OUT @IDORDER  dec(10, 0),
IN @NAME char(20),
IN @IDPAYER dec(6, 0),                   
IN @PRODUCT char(10),

我的PHP代码:

$conn = new PDO(...);

$sql = "{call rec.saveProduct(?,?,?,?,?,?)}";
$rs = $conn->prepare($sql);
$rs->bindParam(1, $msg, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT,300);
$rs->bindParam(2, $state, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT,5);
$rs->bindParam(3, $idOrder, PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT,10);
$rs->bindParam(4, $name, PDO::PARAM_STR);
$rs->bindParam(5, $idPayer, PDO::PARAM_INT);
$rs->bindParam(6, $product, PDO::PARAM_STR);
$rs->execute();

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

当我编写存储过程时,我更喜欢只输入输入参数:

IN @NAME char(20),
IN @IDPAYER dec(6, 0),                   
IN @PRODUCT char(10),

然后在内部我将输出作为结果集返回:

SELECT @MSG AS [MSG], @STATE AS [STATE], @IDORDER AS [IDORDER]

然后在PHP中:

$sql = "{call rec.saveProduct(?,?,?)}";
$rs = $conn->prepare($sql);
$rs->bindParam(1, $name, PDO::PARAM_STR);
$rs->bindParam(2, $idPayer, PDO::PARAM_INT);
$rs->bindParam(3, $product, PDO::PARAM_STR);
$rs->execute();
$row = $rs->fetch();

$msg = $row['MSG'];
$state = $row['STATE'];
$idOrder = $row['IDORDER'];