尝试从CSV导入到wordpress db

时间:2016-03-30 07:31:01

标签: php wordpress csv encoding

我使用以下内容从txt文件导入行

$fp = fopen($storagename, 'r');

while ( !feof($fp) ){
     $line = fgets($fp, 2048);
     $data = str_getcsv($line, '\t');

    $new_line = array(
        "clinic_id" => $data[0],
        "type" => trim($data[2]),
        "date" => $mysql_date,
        "time_from" => $mysql_time_from,
        "time_to" => $mysql_time_to,
        "doc_licsense"=> trim($data[7])
    );
    $wpdb->insert
}

以下是单行示例

Array ( 
[clinic_id] => 20 
[type] => A 
[date] => 2016-04-04 
[time_from] => 16:00:00 
[time_to] => 16:15:00 
[doc_licsense] => 10352 
)

将行插入数据库

Array ( 
[clinic_id] => 0 
[type] => A 
[date] => 0 
[time_from] => 0 
[time_to] => 0 
[doc_licsense] => 0 
)

我认为它可能与编码有关但我无法弄清楚

0 个答案:

没有答案