Codeigniter中的报告 [英] Reports in Codeigniter

查看:238
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆