src/Bi/Db.php
private function SetErrCode()
    {
        $connection_status = @pg_connection_status($this->conn);
        $last_error = @pg_last_error($this->conn);
        $result_error = @pg_result_error($this->conn);
        $last_notice = @pg_last_notice($this->conn);

        $_errors = array();

        if ($connection_status) {
            $_errors[] = ($connection_status?$connection_status:'');
        }
        if ($last_error) {
            $_errors[] = ($last_error?$last_error:'');
        }
        if ($result_error) {
            $_errors[] = ($result_error?$result_error:'');
        }
        if ($last_notice) {
            $_errors[] = ($last_notice?$last_notice:'');
        }

        if (count($_errors) > 0) {
            //$this->errStr .= '<div style="border:1px solid black; margin:4px; padding:4px; background-color:#FFDEAD;"><b>Query:</b> '.$this->last_query . '<br />'.implode('<br />', $_errors)."</div>";
            if ($_REQUEST[act]=='api') {
                foreach ($_errors as $_error) {
                    $lines=explode("\n", $_error);
                    $api_errors[]=$lines;
                }
                $err_string=json_encode(['error'=>'DB_error','errors'=>$api_errors]);//exit;
            } else {
                $err_string='<div class="alert alert-error"><h2>DB Error</h2><b>Query:</b> '.$this->last_query . '<br /><pre class="red">'.implode('<br />', $_errors)."</pre></div>";
            }
            $this->errStr .= $err_string;
            //$this->errStr .="<pre>".print_r($GLOBALS)."</pre>";
            $GLOBALS[no_refresh]=1;
        }
    }
private function SetErrCode()
    {
        $connection_status = @pg_connection_status($this->conn);
        $last_error = @pg_last_error($this->conn);
        $result_error = @pg_result_error($this->conn);
        $last_notice = @pg_last_notice($this->conn);

        $_errors = array();

        if ($connection_status) {
            $_errors[] = ($connection_status?$connection_status:'');
        }
        if ($last_error) {
            $_errors[] = ($last_error?$last_error:'');
        }
        if ($result_error) {
            $_errors[] = ($result_error?$result_error:'');
        }
        if ($last_notice) {
            $_errors[] = ($last_notice?$last_notice:'');
        }

        if (count($_errors) > 0) {
            //$this->errStr .= '<div style="border:1px solid black; margin:4px; padding:4px; background-color:#FFDEAD;"><b>Query:</b> '.$this->last_query . '<br />'.implode('<br />', $_errors)."</div>";
            if ($_REQUEST[act]=='api') {
                foreach ($_errors as $_error) {
                    $lines=explode("\n", $_error);
                    $api_errors[]=$lines;
                }
                $err_string=json_encode(['error'=>'DB_error','errors'=>$api_errors]);//exit;
            } else {
                $err_string='<div class="alert alert-error"><h2>DB Error</h2><b>Query:</b> '.$this->last_query . '<br /><pre class="red">'.implode('<br />', $_errors)."</pre></div>";
            }
            $this->errStr .= $err_string;
            //$this->errStr .="<pre>".print_r($GLOBALS)."</pre>";
            $GLOBALS[no_refresh]=1;
        }
    }
private function SetErrCode ( ) { $ connection_status = @ pg_connection_status ( $ this -> conn ) ; $ last_error = @ pg_last_error ( $ this -> conn ) ; $ result_error = @ pg_result_error ( $ this -> conn ) ; $ last_notice = @ pg_last_notice ( $ this -> conn ) ; $ _errors = array ( ) ; if ( $ connection_status ) { $ _errors [ ] = ( $ connection_status ? $ connection_status : '' ) ; } if ( $ last_error ) { $ _errors [ ] = ( $ last_error ? $ last_error : '' ) ; } if ( $ result_error ) { $ _errors [ ] = ( $ result_error ? $ result_error : '' ) ; } if ( $ last_notice ) { $ _errors [ ] = ( $ last_notice ? $ last_notice : '' ) ; } if ( count ( $ _errors ) > 0 ) { //$this->errStr .= '<div style="border:1px solid black; margin:4px; padding:4px; background-color:#FFDEAD;"><b>Query:</b> '.$this->last_query . '<br />'.implode('<br />', $_errors)."</div>"; if ( $ _REQUEST [ act ] == 'api' ) { foreach ( $ _errors as $ _error ) { $ lines = explode ( "\n" , $ _error ) ; $ api_errors [ ] = $ lines ; } $ err_string = json_encode ( [ 'error' => 'DB_error' , 'errors' => $ api_errors ] ) ; //exit; } else { $ err_string = '<div class="alert alert-error"><h2>DB Error</h2><b>Query:</b> ' . $ this -> last_query . '<br /><pre class="red">' . implode ( '<br />' , $ _errors ) . "</pre></div>" ; } $ this -> errStr .= $ err_string ; //$this->errStr .="<pre>".print_r($GLOBALS)."</pre>"; $ GLOBALS [ no_refresh ] = 1 ; } }
sets error code returned by pgsql
sets error code returned by pgsql