Beispiel #1
0
/**
 * Recupera uma linha de registro da conexão em questão do OCI
 *
 * <code>
 * dbExecute_OCI($dbHandle);
 * </code>
 *
 * @param handle $dbQuery handleId da query OCI
 *
 * @see dbOpen_OCI()
 * @see dbParse_OCI()
 *
 * @since Versão 1.0
 */
function dbExecute_OCI(&$dbHandle, $dbSQL)
{
    $debugBackTrace = debug_backtrace();
    $debugFile = basename($debugBackTrace[1]["file"]);
    $debugFunction = $debugBackTrace[1]["function"];
    $dbDriver = $dbHandle[dbHandleDriver];
    $dbHandleId = $dbHandle[dbHandleId];
    if (!($ociParse = @oci_parse($dbHandleId, $dbSQL))) {
        $e = oci_error($dbHandleId);
        echo "<span style=\"text-align: left;\"><pre><b>{$dbDriver} - {$debugFile} - {$debugFunction}() - Parse</b>:" . "<br /><b>Host</b>: " . $dbHost . "<br /><b>Code</b>: " . $e["code"] . "<br /><b>Message</b>: [" . htmlentities($e["message"]) . "]" . "<br /><b>Offset</b>: " . ($e["offset"] + 1) . "<hr />" . htmlentities(substr($e["sqltext"], 0, $e["offset"])) . "<font color=\"red\"\\><b>Error (" . $e["code"] . ")</b> --&gt; </font>" . htmlentities(substr($e["sqltext"], $e["offset"], 99999));
        echo "<hr />" . debugBackTrace();
        echo "</pre></span>";
        die;
    }
    if (!($ociExecute = @oci_execute($ociParse))) {
        $e = oci_error($ociParse);
        echo "<span style=\"text-align: left;\"><pre><b>{$dbDriver} - {$debugFile} - {$debugFunction}() - Execute</b>:" . "<br /><b>Conexão</b>: " . $dbHost . "<br /><b>Código</b>: " . $e["code"] . "<br /><b>Mensagem</b>: [" . htmlentities($e["message"]) . "]" . "<br /><b>Offset</b>: " . ($e["offset"] + 1) . "<hr />" . htmlentities(substr($e["sqltext"], 0, $e["offset"])) . "<font color=\"red\"\\><b>Erro (" . $e["code"] . ")</b> --&gt; </font>" . htmlentities(substr($e["sqltext"], $e["offset"], 99999));
        echo "<hr />" . debugBackTrace();
        echo "</pre></span>";
        die;
    }
    return $ociExecute;
}
/**
 * Recupera linhas de registro da conexão em questão do MySQL
 *
 * <code>
 * dbExecute_MySQL($mysqlSQL);
 * </code>
 *
 * @param handle $dbExecute handleId da Execute MySQL
 *
 * @see dbOpen_MySQL()
 *
 * @since 1.0
 */
function dbExecute_MSSQL(&$dbHandle, $dbSQL)
{
    $debugBackTrace = debug_backtrace();
    $debugFile = basename($debugBackTrace[1]["file"]);
    $debugFunction = $debugBackTrace[1]["function"];
    $dbDriver = $dbHandle[dbHandleDriver];
    $dbHandleId = $dbHandle[dbHandleId];
    $dbHost = $dbHandle[dbHandleHost];
    $dbDatabase = $dbHandle[dbHandleDatabase];
    if (!($mssqlExecute = @mssql_query($dbSQL, $dbHandleId))) {
        echo "<span style=\"text-align: left;\"><pre><b>{$dbDriver} - {$debugFile} - {$debugFunction}()</b>:" . "<br /><b>Host</b>: " . $dbHost . "<br /><b>Database</b>: " . $dbDatabase . "<br /><b>Message</b>: [" . mssql_get_last_message() . "]";
        echo "<hr />" . debugBackTrace();
        echo "</pre></span>";
        die;
    }
    return $mssqlExecute;
}
/**
 * Recupera uma linha de registro da conexão em questão do pgsql
 *
 * <code>
 * dbQuery_PGSQL($pgsqlSQL);
 * </code>
 *
 * @param handle $dbQuery handleId da query pgsql
 *
 * @see dbOpen_PGSQL()
 *
 * @since Versão 1.0
 */
function dbQuery_PGSQL(&$dbHandle, $dbSQL)
{
    $debugBackTrace = debug_backtrace();
    $debugFile = basename($debugBackTrace[1]["file"]);
    $debugFunction = $debugBackTrace[1]["function"];
    $dbHandleId = $dbHandle[dbHandleId];
    $dbDriver = $dbHandle[dbHandleDriver];
    $dbHost = $dbHandle[dbHandleHost];
    $dbDatabase = $dbHandle[dbHandleDatabase];
    if (!($pgsqlQuery = @pg_query($dbHandleId, $dbSQL))) {
        echo "<span style=\"text-align: left;\"><pre><b>{$dbDriver} - {$debugFile} - {$debugFunction}()</b>:" . "<br /><b>Connection</b>: " . $dbHost . "<br /><b>Database</b>: " . $dbDatabase . "<br /><b>Message</b>: [" . pg_last_error() . "]" . $dbSQL;
        echo "<hr />" . debugBackTrace();
        echo "</pre></span>";
        die;
    }
    return $pgsqlQuery;
}
/**
 * Execute a query on an InterBase database
 *
 * <code>
 * dbExecute_Firebird($firebirdSQL);
 * </code>
 *
 * @param handle $dbExecute handleId da Execute Firebird
 *
 * @see dbOpen_Firebird()
 *
 * @since 1.0
 */
function dbExecute_firebird(&$dbHandle, $dbSQL)
{
    $debugBackTrace = debug_backtrace();
    $debugFile = basename($debugBackTrace[1]["file"]);
    $debugFunction = $debugBackTrace[1]["function"];
    $dbDriver = $dbHandle[dbHandleDriver];
    $dbHandleId = $dbHandle[dbHandleId];
    $dbHost = $dbHandle[dbHandleHost];
    $dbDatabase = $dbHandle[dbHandleDatabase];
    preg_match_all("%^\\s*(?P<sql>.*?)(?P<r>\r)?(?P<n>\n)%sm", $dbSQL . "\r\n", $Matches, PREG_OFFSET_CAPTURE);
    if (preg_last_error()) {
        debugError("<b>preg_last_error</b>:" . preg_last_error());
    }
    $dbSQL = "";
    foreach ($Matches[0] as $key => $value) {
        $dbSQL .= $Matches["sql"][$key][0] . "\r\n";
    }
    if (!($firebirdExecute = @ibase_query($dbSQL, $dbHandleId))) {
        $e = ibase_errmsg();
        preg_match_all("%^(?P<origem>[^=]+)=\\s*(?P<error>-?\\d+)\\s*(?P<message>.*?)\\s*(-|at)\\s*line\\s*(?P<line>\\d+),\\s*column\\s*(?P<column>\\d+)%i", $e, $Matches, PREG_OFFSET_CAPTURE);
        $errorOrigem = $Matches["origem"][0][0];
        $errorError = $Matches["error"][0][0];
        $errorMessage = $Matches["message"][0][0];
        $errorLine = $Matches["line"][0][0];
        $errorColumn = $Matches["column"][0][0];
        echo "<span style=\"text-align: left;\"><pre><b>{$dbDriver} - {$debugFile} - {$debugFunction}()</b>:" . "<br /><b>Database</b>: " . $dbDatabase . "<br /><b>Message</b>: [" . $e . "]";
        preg_match_all("%^(?P<sql>.*?)(?P<r>\r)?(?P<n>\n)%sm", $dbSQL, $Matches, PREG_OFFSET_CAPTURE);
        if (preg_last_error()) {
            debugError("<b>preg_last_error</b>:" . preg_last_error());
        }
        $i = 0;
        $errorColumn -= 1;
        foreach ($Matches[0] as $key => $value) {
            $i++;
            $sql = $Matches["sql"][$key][0];
            echo "<br />";
            if ($i != $errorLine) {
                echo htmlentities($sql);
            } else {
                echo htmlentities(substr($sql, 0, $errorColumn)) . "<font color=\"red\"\\><b>Erro ({$errorError} - {$errorMessage})</b> --&gt; </font>" . htmlentities(substr($sql, $errorColumn, 99999));
            }
        }
        echo "<hr />" . debugBackTrace();
        echo "</pre></span>";
        die;
    }
    return $firebirdExecute;
}
/**
 * Recupera uma linha de registro da conexão em questão do SQLite
 *
 * <code>
 * dbQuery_SQLite($SQLiteSQL);
 * </code>
 *
 * @param handle $dbQuery handleId da query SQLite
 *
 * @see dbOpen_SQLite()
 *
 * @since Versão 1.0
 */
function dbQuery_SQLite(&$dbHandle, $dbSQL)
{
    $debugBackTrace = debug_backtrace();
    $debugFile = basename($debugBackTrace[1]["file"]);
    $debugFunction = $debugBackTrace[1]["function"];
    $dbDriver = $dbHandle[dbHandleDriver];
    $dbHandleId = $dbHandle[dbHandleId];
    $dbFilename = $dbHandle[dbHandleFilename];
    $dbMode = $dbHandle[dbHandleMode];
    if (!($SQLiteQuery = @sqlite_query($dbHandleId, $dbSQL))) {
        echo "<span style=\"text-align: left;\"><pre><b>{$dbDriver} - {$debugFile} - {$debugFunction}()</b>:" . "<br /><b>Filename</b>: {$dbFilename}" . "<br /><b>Mode</b>: {$dbMode}" . "<br /><b>Message</b>: [" . sqlite_last_error($dbHandleId) . "]";
        echo "<hr />" . debugBackTrace();
        echo "</pre></span>";
        die;
    }
    return $SQLiteQuery;
}
Beispiel #6
0
/**
 * Imprime informação na forma de debug no caso de erros
 *
 * Facilita a apresentação de erros durante a execução
 *
 * <code>
 * debugError("Mensagem de erro!");
 * </code>
 *
 * @param string conteúdo que será apresentado
 *
 * @see debugBackTrace()
 *
 * @uses debugBackTrace()
 *
 * @since Versão 1.0
 */
function debugError($varContent, $blnBackTrace = 0)
{
    if ($varContent) {
        $debugBackTrace = debug_backtrace();
        $strFile = basename($debugBackTrace[0]["file"]);
        $strFunction = $debugBackTrace[1]["function"];
        $intLine = $debugBackTrace[0]["line"];
        echo "<pre style=\"text-align: left;\"><b>{$strFile}({$intLine})-&gt;{$strFunction}</b><br />";
        if (is_array($varContent)) {
            print_r($varContent);
        } else {
            echo $varContent;
        }
        if ($blnBackTrace) {
            echo "<hr />" . debugBackTrace();
        }
        echo "</pre>";
        ob_flush();
        flush();
    }
}