简体   繁体   English

PHP和MySQL在数据库中保存公式以生成报告

[英]PHP & MySQL saving a formula in the database for report generation

I am developping/maintaining a web application where different reports and web pages on the portal must be generated automatically and depending on the settings and formula methodes set for a period. 我正在开发/维护一个Web应用程序,其中必须自动生成门户网站上的不同报告和网页,具体取决于为一段时间设置的设置和公式方法。

For instance, the calculation in one month can be ($a+$b) whereas it can be (($a+$b)/2) in the next month or even ($a+$b)/2*100 for a group/type of individuals in a month... 例如,一个月内的计算可以是($ a + $ b),而下个月可以是(($ a + $ b)/ 2)或者一组/($ a + $ b)/ 2 * 100一个月内的个人类型......

On top of this, I want the users (Administrators) to be able to setup the formula methods for a specific period of time, but I am failing to reach this goal 除此之外,我希望用户(管理员)能够在特定时间段内设置公式方法, 但我未能达到此目标

I think this must be a good solution because, my application has a computation center that distributes calculation to PDF reports, XLS exports, Live web pages... and the figures in all these places must be accurate and the same 我认为这一定是一个很好的解决方案,因为我的应用程序有一个计算中心,可以将计算分配到PDF报告,XLS导出,实时网页......所有这些地方的数字必须准确且相同

The question now is: 现在的问题是:

Is there a way of storing the code (php script, code snippet) in the database, along with the date intervals so it can be evaluated "eval()" and perfom the calculations? 有没有一种方法可以在数据库中存储代码(php脚本,代码片段)以及日期间隔,以便可以评估“eval()”并执行计算?

If Yes, Is there a way of creating a user interface that will allow the end user (without programming skills) set up the formula? 如果是,是否有办法创建一个允许最终用户(没有编程技能)设置公式的用户界面?

Any docs? 任何文件? link to read? 链接阅读?

For your information, I build my web apps with CodeIgniter PHP framework 为了您的信息,我使用CodeIgniter PHP框架构建我的Web应用程序

Thanks 谢谢

DO NOT let users write code that gets eval() -ed against your database. 不要让用户编写针对您的数据库获取eval() ed的代码。

The database is for data. 该数据库用于数据。 Code is for code. 代码用于代码。

You'll find writing custom reports in model classes in PHP has these benefits: 您会发现在PHP中的模型类中编写自定义报告具有以下优点:

  • Faster to develop 发展更快
  • Easier to debug 更容易调试
  • Faster to run 更快运行
  • Safer to execute with respect to security vulnerabilities 更安全地执行安全漏洞

Let users specify criteria, and you write application code to interpret their criteria and map that into the code you have written. 让用户指定标准,然后编写应用程序代码来解释他们的标准并将其映射到您编写的代码中。

Some of the users' criteria are simply specific values for date ranges and so on, and you can add these as query parameter binding . 某些用户的标准只是日期范围的特定值等,您可以将它们添加为查询参数绑定

Other criteria change the logic of the reporting queries, and for these you need to call a different report-writer that you have coded. 其他条件会更改报告查询的逻辑,对于这些标准,您需要调用已编码的其他报告编写器。

It's not reasonable for users to demand arbitrary flexibility in report-writing. 用户在报告编写中要求任意灵活性是不合理的。 They won't be happy with the result, either with respect to performance or security. 无论是在性能还是安全方面,他们都不会对结果感到满意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM