|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-08-14 00:01 UTC] nicos@php.net
[2008-08-14 00:04 UTC] nicos@php.net
[2008-08-21 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 18 17:00:01 2025 UTC |
Description: ------------ Into of a loop(while): 1) I open the file handler (w) 2) Caught data on database (MSSQL 2005) 3) Record the data to file (fwrite) 4) Close handler 5) Continue loop until end If the file created (step 3) is large (over +- 25MB), the next query gives error. But if the file is small, the script works well. In my script, I have to make the export of large tables, separated. If I remove the element 'large_table' of the array $tables, the export will work perfectly. Reproduce code: --------------- <?php function replace_characters($value) { return str_replace("'","''",$value); } mssql_connect('server_name','user_name','passwrd') or die('error connect to database'); mssql_select_db('database_name'); $tables = array('large_table','medium_table','small_table','medium_table'); $hadler = ''; foreach($tables as $table) { $handler = fopen("$tabele.sql","w"); $res_sql = mssql_query("SELECT * FROM $table"); while($table_data = mssql_fetch_assoc($res_sql)) { $table_data = array_map('replace_characters',$table_data); fwrite($handler,"INSERT INTO $table values('".implode("','",$table_data)."');\n"); } echo "\n$table exported"; fclose($handler); } echo "export finished"; ?> Expected result: ---------------- large_table exported medium_table exported small_table exported medium_table exported end Actual result: -------------- large_table exported Warning: mssql_query(): Query failed in /htdocs/export_data_as_sql_insert.php on line 15