获取oci_execute()错误的错误消息(PHP) [英] Getting Error Message For oci_execute() Error (PHP)

查看:466
本文介绍了获取oci_execute()错误的错误消息(PHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果Oracle 10g中的查询失败,我想获取特定的错误消息.对于MySQL,PHP具有mysql_error()函数,该函数可以返回有关查询失败原因的详细信息.我检查了php.net手册中的oci_execute()函数,但从我看到的结果来看,它仅在失败时返回false.

I would like to get the specific error message if a query fails in Oracle 10g. For MySQL, PHP has the mysql_error() function that can return details about why a query failed. I check the php.net manual for the oci_execute() function, but from what I see it only returns false on fail.

我尝试使用oc_error(),但没有任何帮助.

I tried using oc_error(), but I am not getting anything from it.

这是一个代码示例:

    $err = array();
    $e = 0;

    //Cycle through all files and insert new records into database
    for($f=0; $f<sizeof($files); $f++)
    {
        $invoice_number = $files[$f]['invoice_number'];
        $sold_to = $files[$f]['sold_to'];
        $date = $files[$f]['date'];

        $sql = "insert into invoice (dealer_id, invoice_number, invoice_date) 
                values ('$sold_to', '$invoice_number', '$date')";

        $stid = oci_parse($conn, $sql);
        $result = oci_execute($stid);

        //If query fails
        if(!$result)
        {
            $err[$e] = oci_error();
            $e++;
        }
    } 

    print_r($err);

print_r($ err)的响应:

Response for print_r($err):

Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => ) 

推荐答案

您是否尝试过将$ stid传递给oci_error?

Have you tried to pass $stid to oci_error?

$err[$e] = oci_error($stid);

这篇关于获取oci_execute()错误的错误消息(PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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