通过PHP调用Oracle存储过程 [英] Oracle Stored Procedure call by PHP

查看:104
本文介绍了通过PHP调用Oracle存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码在这里:

<?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;

结果为过程失败".我在哪里失败? 到目前为止,我只是使用了存储过程调用(但使用游标作为输出),一切都很好.

Result is "Procedure Failed". Where am I failing? I've just used a stored procedure call (but with cursors as output) till now and all was fine.

在Oracle上启动SP可以正常工作,所以这是一个php问题.

Launching the SP on Oracle works fine so it's a php problem.

推荐答案

在我使用某些回显进行调试以打印某些变量的内容时,它可以正常工作.

Magically it works while i was debugging using some echo to print the content of some variables.

这些天我肯定要杀死SysAdmin.

I'm sure i've to kill a SysAdmin for these days wasted.

这篇关于通过PHP调用Oracle存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆