Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.9k views
in Technique[技术] by (71.8m points)

php/oracle oci_fetch_array returns false on query invocation which works in query browser

In Oracle SQL Developer, this works and gives rows on my screen.

  SELECT
            C.LEGALNAME AS NAME,
            C.CSTATE AS STATE,
            P.CUSTNUM AS CUSTNUM,
            P.POLICYNUM AS POLICYNUM,
            P.POLICYSEQ AS POLICYSEQ,
            A.LEGALNAME AS OP,
            TO_CHAR(P.POLEFFECTIVE,'mm/dd/yy') AS EFFECTIVE,
            TO_CHAR(P.CANCELDATE,'mm/dd/yy') AS CANCEL,
            Y.SHORTDESC AS PAYEE,
            Y.EMAILADDR AS EMAILPAYEE,
            R1.SHORTDESC AS PRODUCER,
            R3.SHORTDESC AS CSR
        FROM
            POLICY P LEFT JOIN ARCUST A ON A.LEVEL1ORG = P.LEVEL1ORG AND A.CUSTNUM = P.OUTSIDEPROD,
            ARCUST C,
            PAYEE Y,
            RESPCODE R1,
            RESPCODE R3
        WHERE
            P.LEVEL1ORG = 100 AND
            P.CANCELDATE >= '01-JAN-21' AND
            P.CANCELDATE <= '31-JAN-21' AND
            P.IPPAYEE = :payee AND
            P.POLSTATUS = 'c' AND
            C.LEVEL1ORG = 100 AND
            C.CUSTNUM   = P.CUSTNUM AND
            Y.LEVEL1ORG = 100 AND
            Y.PAYEECODE = P.IPPAYEE AND
            R1.RESPCODE = P.RESP1 AND
            R3.RESPCODE = P.RESP3 AND
            R1.LEVEL1ORG = 100 AND
            R3.LEVEL1ORG = 100

In php, this doesn't (oci_fetch_array) returns false

$Office = $_SESSION['level1org'];  // "100"
$payee  = $_POST['payee'];         // "4000"
$month  = $_POST['month'];         // "1"
$year   = $_POST['year'];          // "2021"

$query = "SELECT
        C.LEGALNAME AS NAME,
        C.CSTATE AS STATE,
        P.CUSTNUM AS CUSTNUM,
        P.POLICYNUM AS POLICYNUM,
        P.POLICYSEQ AS POLICYSEQ,
        A.LEGALNAME AS OP,
        TO_CHAR(P.POLEFFECTIVE,'mm/dd/yy') AS EFFECTIVE,
        TO_CHAR(P.CANCELDATE,'mm/dd/yy') AS CANCEL,
        Y.SHORTDESC AS PAYEE,
        Y.EMAILADDR AS EMAILPAYEE,
        R1.SHORTDESC AS PRODUCER,
        R3.SHORTDESC AS CSR
    FROM
        POLICY P LEFT JOIN ARCUST A ON A.LEVEL1ORG = P.LEVEL1ORG AND A.CUSTNUM = P.OUTSIDEPROD,
        ARCUST C,
        PAYEE Y,
        RESPCODE R1,
        RESPCODE R3
    WHERE
        P.LEVEL1ORG = :Office AND
        P.CANCELDATE >= :startOfMonth AND
        P.CANCELDATE <= :endOfMonth AND
        P.IPPAYEE = :payee AND
        P.POLSTATUS = 'c' AND
        C.LEVEL1ORG = :Office AND
        C.CUSTNUM   = P.CUSTNUM AND
        Y.LEVEL1ORG = :Office AND
        Y.PAYEECODE = P.IPPAYEE AND
        R1.RESPCODE = P.RESP1 AND
        R3.RESPCODE = P.RESP3 AND
        R1.LEVEL1ORG = :Office AND
        R3.LEVEL1ORG = :Office";

$months = [];
$months[0] = '';
$months[1] = 'January';
$months[2] = 'February';
$months[3] = 'March';
$months[4] = 'April';
$months[5] = 'May';
$months[6] = 'June';
$months[7] = 'July';
$months[8] = 'August';
$months[9] = 'September';
$months[10] = 'October';
$months[11] = 'November';
$months[12] = 'December';   

$yearAbbrev = substr($year, 2, 2); 
$monthAbbrev = strtoupper(substr($months[intval($month)], 0, 3));
$lastDayOfMonth = intval(cal_days_in_month(CAL_GREGORIAN, intval($month), intval($year)));  
$startOfMonth = "01-$monthAbbrev-$yearAbbrev";
$endOfMonth = "$lastDayOfMonth-$monthAbbrev-$yearAbbrev";
$getCancelledPolicies = oci_parse($conn, $query);

oci_bind_by_name($getCancelledPolicies, ":Office",          $Office);
oci_bind_by_name($getCancelledPolicies, ":payee",           $payee);
oci_bind_by_name($getCancelledPolicies, ":startOfMonth",    $startOfMonth);
oci_bind_by_name($getCancelledPolicies, ":endOfMonth",      $endOfMonth);
oci_execute($getCancelledPolicies);
while($row = oci_fetch_array($getCancelledPolicies)){

Why?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...