Jump to content

[SOLVED] Logs Retrieved From DB Being Truncated?


Recommended Posts

I have searched high and low and not even found anyone who's had a similar problem. For a server monitoring tool, log files are being pulled from an Oracle database to be displayed in a web interface, but the logs are being displayed truncated in seemingly random places. I've traced the log through the code back to the statement pulling it from the database and it is truncated immediately after that function call. The log is complete in the database.

 

Each log gets truncated the same way every time, but different logs are being truncated in different places, one after 94 characters, one after 200-ish, others after more than 4000 characters. Every log file is being truncated, regardless of its length. The log has type CLOB in the database and here is the code being used to retreive it:

 

public function get_log($id) {
    $query = "SELECT log from job_log where instance_id = $id";
    $output = array();
    if ($resource = oci_parse($this->ora_connection, $query) ) {
        if (oci_execute($resource, OCI_DEFAULT)) {
            while ($result = oci_fetch_array($resource, OCI_ASSOC + OCI_RETURN_NULLS + OCI_RETURN_LOBS)) {
                $output[] = array_change_key_case($result, CASE_LOWER);
            }
        }
    }
    ... return results or empty array ...
}

 

Outputting the retrieved data immediately after the oci_fetch_array gives me the truncated log. I have also tried using oci_fetch_assoc() and then load() to see if using a reference to the clob would work better, but I still got the log, truncated in the same place as always. Neither have I found any special characters (returns, EOFs, etc) in the log files themselves.

 

Has anyone else seen this problem before? How did you solve it? Any assistance is greatly appreciated.

Link to comment
Share on other sites

Effigy, thank you for the character set hint!

 

Here's how I fixed the problem:

In the call to oci_connect, I specified a character set:

oci_connect($user, $pass, $connectString, "WE8ISO8859P15")

where WE8ISO8859p15 is the character set.

 

This page also helped me out:

http://us3.php.net/manual/en/function.oci-connect.php

 

Thanks again.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.