Note that there are some explanatory texts on larger screens.

plurals
  1. POphp+odbc writing to files limitation
    primarykey
    data
    text
    <p>i got a function in PHP to read table from ODBC (to IBM AS400) and write it to a text file on daily basis. it works fine until it reach more than 1GB++. Then it just stop to some rows and didn't write completely.</p> <pre><code>function write_data_to_txt($table_new, $query) { global $path_data; global $odbc_db, $date2; if(!($odbc_rs = odbc_exec($odbc_db,$query))) die("Error executing query $query"); $num_cols = odbc_num_fields($odbc_rs); $path_folder = $path_data.$table_new."/"; if (!file_exists($path_folder)) mkdir ($path_folder,0777); $filename1 = $path_folder. $table_new. "_" . $date2 . ".txt"; $comma = "|"; $newline = chr(13).chr(10); $handle = fopen($filename1, "w+"); if (is_writable($filename1)) { $ctr=0; while(odbc_fetch_row($odbc_rs)) { //function for writing all field // for($i=1; $i&lt;=$num_cols; $i++) // { // $data = odbc_result($odbc_rs, $i); // if (!fwrite($handle, $data) || !fwrite($handle, $comma)) { // print "Cannot write to file ($filename1)"; // exit; // } //} //end of function writing all field $data = odbc_result($odbc_rs, 1); fwrite($handle,$ctr.$comma.$data.$newline); $ctr++; } echo "Write Success. Row = $ctr &lt;br&gt;&lt;br&gt;"; } else { echo "Write Failed&lt;br&gt;&lt;br&gt;"; } fclose($handle); } </code></pre> <p>no errors, just success message but it should be 3,690,498 rows (and still increase) but i just got roughly 3,670,009 rows</p> <p>My query is ordinary select like : </p> <pre><code>select field1 , field2, field3 , field4, fieldetc from table1 </code></pre> <p>What i try and what i assume :</p> <ol> <li>I think it was fwrite limitation so i try not to write all field (just write $ctr and 1st record) but it still stuck in same row.. so i assume its not about fwrite exceed limit..</li> <li>I try to reduce field i select and it can works completely!! so i assume it have some limitation on odbc.</li> <li>I try to use same odbc datasource with SQL Server and try to select all field and it give me complete rows. So i assume its not odbc limitation.</li> <li>Even i try on 64 bits machine but it even worse, it just return roughly 3,145,812 rows.. So i assume it's not about 32/64 bit infrastructure. </li> <li>I try to increase memory_limit in php ini to 1024mb but it didnt work also.. </li> </ol> <p>Is there anyone know if i need to set something in my PHP to odbc connection?? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload