Codeigniter 中的报告 [英] Reports in Codeigniter

查看:15
本文介绍了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天全站免登陆