从php在PL/SQL中传递参数时出现问题


Problems passing parameters in PL/SQL from php

这是我第一次开发应用程序pl/sql,在将参数传递到php-pl/sql时遇到了一些困难。PL/SQL函数已经在数据库中创建,当运行以下查询时,它会返回到期参数:

BEGIN 
  PIN_USERNAME := 'admin';
  PIN_PASSWD := '1';
  POUT_MESSAGE := NULL;
  RetVal := PKG_LOGIN.LOGIN_PORTAL ( PIN_USERNAME, PIN_PASSWD, POUT_MESSAGE );
  DBMS_OUTPUT.PUT_LINE('PIN_USERNAME='||PIN_USERNAME);
  DBMS_OUTPUT.PUT_LINE('PIN_PASSWD='||PIN_PASSWD);
  DBMS_OUTPUT.PUT_LINE('POUT_MESSAGE='||POUT_MESSAGE);
  COMMIT; 
END; 

现在的问题是我不能在php中做同样的事情。以下是我在谷歌的帮助下开发的php代码:

include 'define.php';
require_once '../config/connectDB.php';
if(isset($_POST['user']) && isset($_POST['senha']))
{
    $utilizador = $_POST['user'];
    $senha = $_POST['senha'];
    $msg;
    //Connection database
    if(!ligacaoDB())
    {
        echo "Dont Connect";
    }
    $query = "begin :r := PKG_LOGIN.LOGIN_PORTAL (:1, :2, :3); commit; end;";    
    $result = oci_parse(ligacaoDB(), $query);     
    oci_bind_by_name($result, ":1", $utilizador);
    oci_bind_by_name($result, ':2', $senha);
    oci_bind_by_name($result, ':3', $msg);
    oci_bind_by_name($result, ':r', $r);
    $xpto = oci_execute($result);

    if($xpto == false)
    {
        $e = oci_error($result);
        print htmlentities($e['message']);
    }
    else
    {
        echo $msg . " | " . $r;
    }
    oci_free_statement($result);
    oci_close(ligacaoDB());
}

根据我对plsql函数的理解,这个参数接收userpassword检查数据库,并返回由msgr表示的消息和布尔值。

有人能帮助我并向我解释谁可能做错了吗?

你发现原因了吗。对于那些有同样问题的人,这里是我的答案:

http://docs.oracle.com/cd/E11882_01/appdev.112/e10646/oci03typ.htm#CEGIEEJI

以下两种类型是PL/SQL内部的,无法返回作为OCI:的值

布尔值,SQLT_BOL

记录,SQLT_REC