CodeIgniter和csv_from_result [英] CodeIgniter and csv_from_result
本文介绍了CodeIgniter和csv_from_result的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从数据库获取数据并使用
$ query = $ this-> db-> query SELECT * FROM mytable);
echo $ this-> dbutil-> csv_from_result($ query);
但是我想更改头文件名称为first_name的CSV是First Name ...
解决方案
div>
尝试重命名sql查询返回的列:
$ query = $ this-> db-> ; query(
SELECT
first_name as'First Name',last_name as'Last Name'
FROM mytable
);
缺点是你必须列出列而不是简单的 *
。
I have getting data from a database and using
$query = $this->db->query("SELECT * FROM mytable");
echo $this->dbutil->csv_from_result($query);
however I want to change the name of my headers for the CSV for first_name is First Name...how would I go about doing that?
Thanks, J
解决方案
Try renaming the columns returned by the sql query:
$query = $this->db->query("
SELECT
first_name as 'First Name', last_name as 'Last Name'
FROM mytable
");
The downside is that you will have to list the columns instead of a simple *
.
这篇关于CodeIgniter和csv_from_result的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文