Mysql 如何使用drupal中的加载数据填充将数据从csv加载到db
我已经在drupal db中尝试了以下用于内联文件的代码Mysql 如何使用drupal中的加载数据填充将数据从csv加载到db,mysql,drupal,drupal-6,Mysql,Drupal,Drupal 6,我已经在drupal db中尝试了以下用于内联文件的代码 $sql = "LOAD DATA INFILE '".db_escape_string($this->file_name). "' INTO TABLE `".$this->table_name. "` FIELDS TERMINATED BY '".db_escape_string($this->field_separate_char). "' OPTIONAL
$sql = "LOAD DATA INFILE '".db_escape_string($this->file_name).
"' INTO TABLE `".$this->table_name.
"` FIELDS TERMINATED BY '".db_escape_string($this->field_separate_char).
"' OPTIONALLY ENCLOSED BY '".db_escape_string($this->field_enclose_char).
"' ESCAPED BY '".db_escape_string($this->field_escape_char).
"' ".
($this->use_csv_header ? " IGNORE 1 LINES " : "")
."(`".implode("`,`", $this->arr_csv_columns)."`)";
$res = db_query($sql);
$this->error = mysql_error();
我得到了错误,但该文件存在于文件夹中
用户警告:未找到文件“http:\localhost\example\sites\default\files\example\u 1.csv”(错误代码:22)查询:加载数据填充”http://localhost/example/sites/default/files/example_1.csv'INTO TABLEtemp\U 21\U 10\U 2010\U 06\U 38\U 00
字段以“,”结尾,也可以用“\”括起来,用“\”转义,忽略1行(C:\wamp\www\example\sites\all\modules\importmodule\Quick\u CSV\u import.php第65行中的PROGRAMNAME
,OFFLINE
,ONLINE
,ONLINE
,INSTOCK
)
在第65行,上面的php代码
$res=db_query($sql);
存在。可能是因为?可能是因为?您需要指定csv文件的完整/绝对或相对路径,而不是URL
load data infile '/myproj/imports/example_1.csv' into table...
load data infile 'c:\\myproj\\imports\\example_1.csv' into table...
建议您再次查看手册您需要指定csv文件的完整/绝对或相对路径,而不是URL
load data infile '/myproj/imports/example_1.csv' into table...
load data infile 'c:\\myproj\\imports\\example_1.csv' into table...
建议您再次查看该手册上述代码在php中运行良好,但我无法通过drupal获得。与独立php脚本相比,您与drupal的路径不同。在Windows中,我必须使用“/”斜杠作为路径分隔符。上述代码在php中运行良好,但我无法通过drupal获得。您将有一个不同点从drupal获得的路径比在独立php脚本中的路径更为不同。在Windows中,我必须使用“/”斜杠作为路径分隔符