From 44ff2837cd2da5345914774c7aba0fdf4deef7f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9lder=20Duarte?= Date: Thu, 14 Jun 2018 11:31:58 +0100 Subject: [PATCH] Allow string parameters --- src/JasperPHP/JasperPHP.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/JasperPHP/JasperPHP.php b/src/JasperPHP/JasperPHP.php index 1414104..423aed5 100644 --- a/src/JasperPHP/JasperPHP.php +++ b/src/JasperPHP/JasperPHP.php @@ -95,7 +95,10 @@ public function process($input_file, $output_file = false, $format = array("pdf" $command .= " -P"; foreach ($parameters as $key => $value) { - $command .= " " . $key . "=" . $value; + if( is_string($value) ) + $command .= " $key=\"$value\""; + else + $command .= " $key=$value"; } } @@ -105,7 +108,7 @@ public function process($input_file, $output_file = false, $format = array("pdf" if( isset($db_connection['username']) && !empty($db_connection['username']) ) $command .= " -u " . $db_connection['username']; - + if( isset($db_connection['password']) && !empty($db_connection['password']) ) $command .= " -p " . $db_connection['password']; @@ -129,10 +132,10 @@ public function process($input_file, $output_file = false, $format = array("pdf" if ( isset($db_connection['db_sid']) && !empty($db_connection['db_sid']) ) $command .= ' --db-sid ' . $db_connection['db_sid']; - + if ( isset($db_connection['json_query']) && !empty($db_connection['json_query']) ) $command .= ' --json-query ' . $db_connection['json_query']; - + if ( isset($db_connection['data_file']) && !empty($db_connection['data_file']) ) $command .= ' --data-file ' . $db_connection['data_file']; @@ -184,10 +187,9 @@ public function execute($run_as_user = false) if( $return_var != 0 && isset($output[0]) ) throw new \Exception($output[0], 1); - elseif( $return_var != 0 ) throw new \Exception("Your report has an error and couldn't be processed! Try to output the command using the function `output();` and run it manually in the console.", 1); - + return $output; } }