在碧玉报告中,我有一个这样的 sql 语句:
SELECT * FROM table $P!{my_where}
在我的 php 程序中,我以这种方式调用报告:
JasperPHP::process(
base_path() . '/app/reports/report.jasper',
false,
array("pdf"),
array("my_where" => "WHERE field = value"),
\Config::get('database.connections.mysql')
)->execute();
然后,这是错误消息:
报告参数格式错误!
以简单的方式进行操作,我的意思是:
在报告中:
SELECT * FROM table WHERE $P!{field} = $P{value}
在 PHP 中:
JasperPHP::process(
base_path() . '/app/reports/report.jasper',
false,
array("pdf"),
array("field" => $my_field, "value" => $my_value),
\Config::get('database.connections.mysql')
)->execute();
问题是,我需要从几个字段动态构建一个 where 子句,因此,必须传递一个唯一的“where”参数。
任何的想法?