Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support to Collections #64

Closed
flavioribeirojr opened this issue Sep 25, 2017 · 22 comments
Closed

Support to Collections #64

flavioribeirojr opened this issue Sep 25, 2017 · 22 comments

Comments

@flavioribeirojr
Copy link

I don't know if is lack of my knowledge, but i can't discover how to pass parameters that in my report are of the Collection type. Do your library support it?

@geekcom
Copy link
Member

geekcom commented Sep 27, 2017

Hi @flavio-jr,

Parameters can be used in SQL queries to filter records in a where condition or to add/replace pieces of raw SQL or even to pass the entire SQL string to execute.
In the first case the parameters are used as standard SQL parameters, in example:

SELECT * FROM ORDERS WHERE ORDER_ID = $P{my_order_id}

In this example my_order_id is a parameter that contains the ID of the order to read. This parameter can be passed to the report from the application that is running it to select only a specific order. Please note that the parameter here is a real SQL parameter, meaning that the query will be executed using a prepared statement like:

SELECT * FROM ORDERS WHERE ORDER_ID = ?

Please read this article:
https://community.jaspersoft.com/wiki/using-report-parameters

@flavioribeirojr
Copy link
Author

I want to use a WHERE IN statement in my SQL, so i'm passing many ids to my report. In iReport they use a Collection parameter to filter the registers. I just want to know if is possible to pass such parameter type from PHP to Jasper

@flavioribeirojr
Copy link
Author

Here is my workaround: I'm passing a string parameter, and in the report I make a "split" to get an array.

@rafaelqueiroz
Copy link
Contributor

@flavio-jr you can provide me a sample of your report ?

@miltonisaya
Copy link

PE8b.zip
Provided is the .jrxml file I am working on. I want to pass my parameters using your library. I keep on getting the array to string conversion error. Please assist

@tantanito
Copy link

@flavio-jr Do you have a working example? Can't get to work with collections.

@hemimm
Copy link

hemimm commented May 2, 2018

When I put a parameters we have a Fatal error: Uncaught PHPJasper\Exception\ErrorCommandExecutable: your report has an error couldn´t be processed.

I did in JasperSoft Studio: Select * from table Where field between P{field_start} and P{field_end}

In PHPJasper:
require DIR.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
use PHPJasper\PHPJasper as PHPJasper;

$file = 'DataMatrix.jasper';
$fieldstart = 'CA1234';
$fieldend = 'CA5678';

$input = DIR.DIRECTORY_SEPARATOR.$file;
$output = DIR;
$options => [
'format' => ['pdf'],
'locale' => 'en'
'params => [
'field_start' => $fieldstart,
'field_end' => $fieldend
],
'dbconnection => [
'driver' => 'mysql',
'username' => 'root',
'password' => 'password',
'host' => 'localhost:8080',
'database' => 'database',
'port' => '3306'
]
$jasper = new PHPJasper;
$jasper -> process($input,$output,$options)->execute();

Without parameters result a blank report, With partameters result the error.

I couldn´t find out the error. I thank for help, and sorry for my bad english.

@geekcom
Copy link
Member

geekcom commented May 3, 2018

Hi @hemimm please check your .jrxml report,
parameters should be used in this way:

$P{my_order_id}

@hemimm
Copy link

hemimm commented May 3, 2018

As my english is not good, I will add information in portuguese.

Para ver as informações passadas, coloque $jasper->process($input,$output,$options)->output e obtive
Jasper starter --locale em process "D:\web\DataMatrix.jasper" -o "D:\web" -f pdf -P field_start = "CA1234" field_end "CA5678" -t mysql -u root -p password -H localhost:8080 -n database --d-port 3306

Espero que com isto ajude a solucionar o problema.

@hemimm
Copy link

hemimm commented May 3, 2018

Yes, it is in this way.

@hemimm
Copy link

hemimm commented May 3, 2018

In JasperSoft Studio, the report is normal, but not in PHPJasper

@hemimm
Copy link

hemimm commented May 3, 2018

the complete error:

Fatal error: Uncaught PHPJasper\Exception\ErrorCommandExecutable: 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. in D:\web\vendor\geekcom\phpjasper\src\PHPJasper.php:219 Stack trace: #0 D:\web\RotulosdaEtiquetasPHPJasper.php(157): PHPJasper\PHPJasper->execute() #1 {main} thrown in D:\web\vendor\geekcom\phpjasper\src\PHPJasper.php on line 219

@hemimm
Copy link

hemimm commented May 3, 2018

line 157 is $jasper($input,$output,$options)->execute()

@hemimm
Copy link

hemimm commented May 3, 2018 via email

@hemimm
Copy link

hemimm commented May 4, 2018 via email

@hemimm
Copy link

hemimm commented May 7, 2018

Se o PhpJasper não é capaz de gerar este tipo de relatório, irei procurar outro tipo de gerador de pdf. Mas antes gostaria que se pronunciassem a respeito.
At.

@hemimm
Copy link

hemimm commented May 7, 2018

Vamos encerrar a solicitação, considerando como NÃO RESOLVIDO. Se eu achar uma solução postarei para vocês. At.

@geekcom
Copy link
Member

geekcom commented May 9, 2018

@hemimm PHPJasper é capaz de resolver sua demanda, acredito que exista algum problema de configuração aí, por favor verifique o manual com atenção.

@hemimm
Copy link

hemimm commented May 9, 2018 via email

@geekcom
Copy link
Member

geekcom commented Jun 13, 2018

Olá @hemimm, dê uma olhada no repositório de exemplos e estude um pouco mais de PHP, percebo que o problema não está na biblioteca.

Take a look at the examples repository and study a little more of PHP, I realize that the problem is not in the library

@geekcom geekcom closed this as completed Jun 13, 2018
@hemimm
Copy link

hemimm commented Jun 13, 2018 via email

@hemimm
Copy link

hemimm commented Jun 14, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants