尝试使用 codeigniter 在我的服务器上保存一个 csv 文件。
我的语法是:
$this->load->dbutil();
$query = $this->db->query("SELECT id,customeraccount,band FROM Customer_Bands");
$delimiter = ',';
$newline = "<br>";
echo $this->dbutil->csv_from_result($query, $delimiter, $newline);
if ( ! write_file(base_url().'/application/authorizations/test.csv', $this->dbutil->csv_from_result($query, $delimiter, $newline)))
{
echo 'Unable to write the file';
}
else
{
echo 'File written!';
}
现在这很粗糙,但希望首先让功能正常工作。
两个问题。首先echo $this->dbutil->csv_from_result($query, $delimiter, $newline);
正确输出到我的视图,但每个字段都在“”内,我该如何删除这些?
其次,该文件没有写入我的服务器。base_url() 是我的 codeigniter 根文件夹,然后在应用程序中我创建了一个名为授权的文件夹,所以base_url()/application/authorizations
这目前失败并回声'Unable to write the file'
提前致谢