Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
Merge pull request #98 from cossou/allow-string-parameters
Browse files Browse the repository at this point in the history
Allow string parameters
  • Loading branch information
cossou authored Jun 14, 2018
2 parents c4d9f7a + 44ff283 commit afda44a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/JasperPHP/JasperPHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}

Expand All @@ -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'];

Expand All @@ -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'];

Expand Down Expand Up @@ -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;
}
}

0 comments on commit afda44a

Please sign in to comment.