下面的代码:Oracle存储过程调用由PHP
<?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问题。
如果我是你,我会chec如果可能,请将PHP的'PDO'扩展(http://php.net/manual/en/book.pdo.php),因为它支持Oracle数据库并调用存储过程。 – 2010-07-09 11:01:13
我一定会看看它,但没有理由代码不起作用? 完全相同的“模板”代码与其他SP在同一数据库上一起使用,并且工作正常: – theCrius 2010-07-09 15:10:25