久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 php 和 mysql 創建 csv 文件時是否有文件大小限

is there a file size limit when creating a csv file using php and mysql?(使用 php 和 mysql 創建 csv 文件時是否有文件大小限制?)
本文介紹了使用 php 和 mysql 創建 csv 文件時是否有文件大小限制?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試創建一個 csv 文件來更新我在 Magento 中的庫存.我的代碼如下:

I am attempting to create a csv file to update my inventory in Magento. My code is as follows:

    <?php
require_once ('../db.php');

$conn = db_connect();
$inventory = array();
$csvContent = "";
$n=0;


$result = $conn->query("select inventory.sku, book.author, book.title,
 book.publisher,     book.pub_date, book.edition,
inventory.isbn13, book.binding, book_condition.book_condition, defect.defect, note,    
feature, inventory.ourPrice, inventory.cost, inventory.quantity, subtitle, weight
from inventory
LEFT JOIN book on book.isbn13 = inventory.isbn13
LEFT JOIN defect on inventory.defect_id = defect.defect_id
LEFT JOIN note on inventory.note_id = note.note_id
LEFT JOIN feature on inventory.feature_id = feature.feature_id
LEFT JOIN book_condition on book_condition.condition_id = defect.condition_id
where inventory.quantity >0");

$num_rows = $result->num_rows;

if($num_rows > 0)
{ 
while($row = $result->fetch_assoc())
{
$inventory[$n] = array('sku' => $row['sku'],
        'author' => $row['author'],
                    /*'title' => $row['title'],
                    'publisher' => $row['publisher'],
                    'pub_date' => $row['pub_date'],
                    'edition' => $row['edition'],
                    'publisher' => $row['publisher'],
                    //'isbn10' => $isbn10,
                    'isbn13' => $row['isbn13'],
                    'binding' => $row['binding'],
                    'condition' => $row['condition'],
                    'defects' => $row['defect'],
                    'notes' => $row['note'],
                    'feature' => $row['feature'],
                    'price' => number_format($row['ourPrice'], 2, '.', ''),
        'cost' => $row['cost'],
                    'description' => $row['defect'],
                    'quantity' => $row['quantity'],
        'store' => "default",
        'websites' => "base",
        'attribute_set' => "books",
        'type' => "simple",
        'category' => "6",
        'type' => "simple",
        'image' => "/bcpics/".$row['isbn13'].".gif",
        'small_image' => "/bcpics/".$row['isbn13'].".gif",
        'thumbnail' => "/bcpics/".$row['isbn13'].".gif",
        'page_layout' => "No Layout updates",
        'options_container' => "Block after Info Column",
        'weight' => $row['weight'],
            'status' =>"Enables",
        'tax_class_id' =>"Taxable Goods", 
        'visibility'  =>"Catalog, Search",
        'enable_googlecheckout'  =>"yes",
        'is_recurring'  =>"no",
        'min_qty'  =>"0",*/
        'use_config_min_qty' =>"1",
        'is_qty_decimal'  =>"0",
        'backorders'  =>"0",
        'use_config_backorders' =>"1",
        'min_sale_qty' =>"1",
        'use_config_min_sale_qty' =>"1",
        'max_sale_qty'  =>"0",
        'use_config_max_sale_qty' =>"1",
        'is_in_stock' =>"1",
        'use_config_notify_stock_qty' =>"1",
        'manage_stock' =>"0",
        'use_config_manage_stock' =>"1",
        'stock_status_changed_automatically' =>"0",
        'use_config_qty_increments' =>"1",
        'qty_increments' =>"0",
        'use_config_enable_qty_increments' =>"1",
        'enable_qty_increments' =>"0",
        'store_id' =>"1",
        'product_type_id' =>"simple",
        'add_delete' => "",
        'url_key' => "",
        'gift_message_available' => "",
        'Topic' => "",
        'Subtitle'=> $row['subtitle'],
        'meta_title' => "",
        'meta_description' => "",
        'custom_design' => "",
        'url_path' => "",
        'special_price' => "",
        'meta_keyword' => "",
        'custom_layout_update' => "",
        'news_from_date' => "",
        'news_to_date' => "",
        'special_from_date' => "",
        'special_to_date' => "",
        'custom_design_from' => "",
        'custom_design_to' => "",
        'low_stock_date' => "",
        'notify_stock_qty' => "",
        'product_status_changed' => "",
        'product_changed_websites'=> "",
        'has_options'=> "0"

            );
    //print_r($inventory);die;
    $n++;
    } //end of while loop
} // end of if statement

$csvInventory = to_csv($inventory);

function to_csv( $array ) {
 $csv = "";

 if (count($array) == 0) return "No SKU's found";

 ## Grab the first element to build the header
 $arr = array_pop( $array );
 $temp = array();
 foreach( $arr as $key => $data ) {
   $temp[] = $key;
 }
 $csv = implode( ',', $temp ) . "
";

 ## Add the data from the first element
 $csv .= to_csv_line( $arr );

 ## Add the data for the rest
 foreach( $array as $arr ) {
   $csv .= to_csv_line( $arr );
 }

 return $csv;
}

function to_csv_line( $array ) {
 $temp = array();
 foreach( $array as $elt ) {
   $temp[] = '"' . addslashes( $elt ) . '"';
 }

 $string = implode( ',', $temp ) . "
";

 return $string;
}

$conn->close();

$myFile = "/home/bookcell/public_html/testbcos/web/inv/BCWebsite" . date("mdY") . ".csv";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $csvInventory;
fwrite($fh, $stringData);
fclose($fh);

我的問題是,如果我嘗試使用 $inventory[$n] = array() 中的所有參數,我將無法讓它工作.我可以一次讓數組中的大約 30 行以外的所有行工作,目前 /**/ 中的所有內容都將不起作用.我玩過更改 /**/ 之間的字段,所以我知道每一行都會毫無問題地進入 csv.我檢查了我服務器上的錯誤日志,沒有錯誤,傳輸日志顯示它應該可以工作.有人看到我哪里出錯了嗎?有沒有更好的方法可以得到我需要的結果?

My problem is that I can't get it to work if I try to use all the parameters in the $inventory[$n] = array(). I can get all but about 30 rows in the array to work at one time, currently everything in the /* and */ will not work. I have played with changing the fields between /* and */ so I know that each row will go into the csv without a problem. I have checked the error logs on my server and there is no error, and the transfer log shows that it should be working. Anyone see where I am going wrong here? Is there a better way to do this that will get the results I need?

推薦答案

我已經從 PHP 和 MySQL 導出了 600MB+ 大小的 csv 文件,這與您沒有問題的方式類似.聽起來像是您的環境設置有問題,而不是代碼或技術限制.

I have exported 600MB+ sized csv files from PHP and MySQL in a similar way that you are with no issues. Sounds like a problem with your environment settings - not with the code or a limitation of the technologies.

這篇關于使用 php 和 mysql 創建 csv 文件時是否有文件大小限制?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 日韩在线精品强乱中文字幕 | 农村黄性色生活片 | 欧美日韩一区二区三区视频 | a视频在线播放 | 天天综合久久 | 欧美激情99 | 97超碰在线播放 | 四虎影音 | 久久久福利 | 天天艹日日干 | 伊人免费在线观看 | 久久久久久久国产精品视频 | 一区二区三区四区在线 | 国产精品不卡 | 亚洲精品乱码久久久久久按摩观 | 手机看片1 | 天天拍天天色 | 欧美一区二区三区在线观看视频 | 欧美日韩一区在线观看 | 精品视频一区二区三区在线观看 | 人人干人人超 | 在线免费观看黄色 | 成人黄页在线观看 | 中文精品视频 | 精品国产乱码久久久久久闺蜜 | 韩日一区| 国产精品久久久亚洲 | 尤物在线 | 成人网av | 日韩一区二区av | 久久国产精品一区二区三区 | 久热国产在线 | 国产精品国产 | 国产黄色大片网站 | 国产特级毛片 | 在线视频一区二区三区 | 亚洲视频免费在线看 | 黄色毛片免费视频 | 欧美大片一区二区 | 欧洲毛片 | 国产精品高潮呻吟久久av黑人 |