PHP 批量导入csv到drupal数据库
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 批量导入csv到drupal数据库相关的知识,希望对你有一定的参考价值。
/**
* function to batch update the sell_price for ubercart products from a csv file
* @param string path to csv file
*/
function sitehelper_batchupdate($csv_file) {
$row = 1;
if (($handle = fopen($csv_file, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 10000, ",")) !== FALSE) {
$num = count($data);
//print $num;
//print "<p> $num fields in line $row: <br /></p>\n";
$row++;
//print $data[0] . " " . $data[1] . $data[2] . $data[3] . "<br />" ;
db_query('update uc_products set sell_price = "%s" where nid = %d and vid = %d', $data[0], $data[2], $data[3]);
}
fclose($handle);
}
}
//sitehelper_batchupdate("http://[site_url]/sites/all/modules/sitehelper/books.csv");
以上是关于PHP 批量导入csv到drupal数据库的主要内容,如果未能解决你的问题,请参考以下文章