【发布时间】:2011-03-13 19:17:13
【问题描述】:
代码如下:
<?php
include_once 'config.php';
// Connect to database
$conn = oci_connect($dbuser, $dbpasswd, $dbhost."/".$dbname);
if (!$conn) {
exit ("Connection failed.");
}
$id = isset($_GET['id']) ? (int)$_GET['id'] : false;
$type = isset($_GET['type']) ? strtoupper($_GET['type']) : "BLOG";
$stmt = oci_parse($conn,
"begin
PKG_LIKE.get_LikeId(
:I_N_Id,
:I_S_Type,
:O_N_grade,
:O_N_exitFlag,
:O_S_exitMsg);
end;");
oci_bind_by_name($stmt, "I_N_Id", $id);
oci_bind_by_name($stmt, "I_S_Type", $type);
oci_bind_by_name($stmt, "O_N_grade", $total);
oci_bind_by_name($stmt, "O_N_exitFlag", $flag);
oci_bind_by_name($stmt, "O_S_exitMsg", $message);
if (!oci_execute($stmt)) {
exit("Procedure Failed.");
}
if ($message == 'OK') {
$response = array('likeit' => $total);
$toReturn = "var response=".json_encode($response)."; showTotalLikeit(response);";
} else {
$response = array('likeit' => 'NaN', 'exitFlag' => $flag, 'exitMsg' => $message);
$toReturn = "var response=".json_encode($response)."; showTotalLikeit(response);";
}
print $toReturn;
结果是“程序失败”。我哪里失败了? 到目前为止,我刚刚使用了一个存储过程调用(但使用游标作为输出),一切都很好。
在 Oracle 上启动 SP 工作正常,所以这是一个 php 问题。
【问题讨论】:
-
如果我是你,我会尽可能查看 PHP 的
PDO扩展名 (php.net/manual/en/book.pdo.php),因为它支持 Oracle 数据库并调用存储过程。 -
我肯定会看它,但没有理由代码不起作用?完全相同的“模板”代码与同一数据库上的其他 SP 一起使用并且工作正常:|
标签: php oracle stored-procedures