Codeigniter中的报告 [英] Reports in Codeigniter
问题描述
在Codeigniter框架中生成报告最简单的方法是什么?有任何库可以执行此任务吗?
What is the most simplist way to generate reports in Codeigniter framework? Is there any library available to do this task? Except charting what are the other resources to do this.
推荐答案
自己找到一个不错的解决方案。如果你想生成报告csv格式这是很容易与codeigniter。
您的模型函数
Found a nice solution myself. If you want to generate reports in csv format it is very easy with codeigniter. Your model function
function index(){
return $query = $this->db->get('my_table');
/*
Here you should note i am returning
the query object instead of
$query->result() or $query->result_array()
*/
}
现在在控制器
function get_report(){
$this->load->model('my_model');
$this->load->dbutil();
$this->load->helper('file');
/* get the object */
$report = $this->my_model->index();
/* pass it to db utility function */
$new_report = $this->dbutil->csv_from_result($report);
/* Now use it to write file. write_file helper function will do it */
write_file('csv_file.csv',$new_report);
/* Done */
}
不需要任何外部在codeigntier。干杯!
如果你想编写xml文件,也很容易。
只需使用dbutil的 xml_from_result()
方法,并使用 write_file('xml_file.xml,$ new_report)
访问这些链接,他们会帮助您。
No externals are required everything is available in codeigntier. Cheers!
If you want to write xml file it is easy too.
Just use xml_from_result()
method of dbutil and use write_file('xml_file.xml,$new_report)
Visit these links they will help.
和
这篇关于Codeigniter中的报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!