Alejeather Posted September 6, 2007 Share Posted September 6, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/68235-solved-logs-retrieved-from-db-being-truncated/ Share on other sites More sharing options...
effigy Posted September 6, 2007 Share Posted September 6, 2007 What character set is this table using? Are there any special characters or non-printing characters in the table? Quote Link to comment https://forums.phpfreaks.com/topic/68235-solved-logs-retrieved-from-db-being-truncated/#findComment-343030 Share on other sites More sharing options...
Alejeather Posted September 6, 2007 Author Share Posted September 6, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/68235-solved-logs-retrieved-from-db-being-truncated/#findComment-343223 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.