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

$P!{name} Parameters #46

Closed
gamadoleo opened this issue Jun 9, 2021 · 11 comments
Closed

$P!{name} Parameters #46

gamadoleo opened this issue Jun 9, 2021 · 11 comments

Comments

@gamadoleo
Copy link
Contributor

how to work with this type of parameter, used for example to pass sql statements, I know it may be a failure for sql injector but it will not be used for parameter edited by the user and in jasperReporta it works normally. I wanted to know how to adopt in your api.

select * from pessoa where ($P!{p_where})

??

@gamadoleo gamadoleo changed the title $P!{name} $P!{name} Pameters Jun 9, 2021
@gamadoleo gamadoleo changed the title $P!{name} Pameters $P!{name} Parameters Jun 9, 2021
@gamadoleo
Copy link
Contributor Author

Can anyone pass these parameters?

@Rctnet
Copy link
Member

Rctnet commented Jun 10, 2021

Hi,
this is a complex sql, i use it in my systems
SELECT p.proprietarios_codigo,
p.proprietarios_nome,
cc.cc_terceiros_codigo,
cc.bancos_codigo,
cc.cc_terceiros_agencia,
cc.cc_terceiros_conta,
cc.cc_terceiros_tipo,
cc.cc_terceiros_titular,
cc.cc_terceiros_cnpjcpf,
l.locacoes_codigo,
b.bancos_nome
FROM locacoes l
JOIN imoveis_proprietarios ip ON ip.imoveis_codigo = l.imoveis_codigo
JOIN cc_terceiros cc ON cc.cc_terceiros_codigo = ip.cc_terceiros_codigo
JOIN proprietarios p ON p.proprietarios_codigo = ip.proprietarios_codigo
JOIN bancos b ON b.bancos_codigo = cc.bancos_codigo
JOIN eventos_locacao evl ON l.locacoes_codigo = evl.locacoes_codigo
WHERE evl.proprietario_dta_venc >= "$P{dta_repasse_inicial}"
AND evl.proprietario_dta_venc <= "$P{dta_repasse_final}"
AND evl.situacao = "NOR"
$P{rd_filtrar_pagos} //here pass a complex condition part of sql ex.: AND foo = bar AND tree = wood
$P{rd_filtrar_prop_imov}
$P{rd_filtrar_repassados}
GROUP BY p.proprietarios_codigo,cc.cc_terceiros_conta
ORDER BY p.proprietarios_nome ASC

@gamadoleo
Copy link
Contributor Author

I understand, in making filters based on individual parameters, but that makes the sql assembly much more complex... something that in the application there are many filters and makes them dynamic, so when passing the formulated parameter already as a kind of p_where, it makes it easier the process a lot, and as I said that way jasperreport native jasper api supports... and it makes it much easier to use this type of parameter, with that I pass a completely customized p_where.

@Rctnet
Copy link
Member

Rctnet commented Jun 10, 2021

ok,i think to support it,
what you pass in ($ P! {p_where}) parameter?

@gamadoleo
Copy link
Contributor Author

step a sql ex:
select * from person where ($P!{p_where})
I pass a sql in the parameter
p_where = city_id=10 and neighborhood_id=25

final result
select * from person where (city_id=10 and neighborhood_id=25)

just an example, that is, I pass a sql script that filters the records, so I can pass a very complex sql with several filters...

@Rctnet
Copy link
Member

Rctnet commented Jun 10, 2021

try this ($P{p_where}) without "!"
select * from person where ($P{p_where})
and pass a sql in the parameter
p_where = city_id=10 and neighborhood_id=25

@gamadoleo
Copy link
Contributor Author

Without ! seems to solve yes... because I did a debug printing the generated sql and now yes it is generating correctly... but I have other problems in the report anything I open another post. Here's just one suggestion that I inform you is the possibility of changing the patch directory of ini config files for database connection because in my case, I already have this file pattern because I also use PDO so I wanted to use the same files...
One question what makes a report slow? because I'm testing your library I already use the report with jar JasperStart but your generated even slower... I didn't understand.

@Rctnet
Copy link
Member

Rctnet commented Jun 10, 2021

About PDO, i use one solution, runs perfect for me, you can change on line

//use TTransaction;

and implement a copy of Transaction Class, but taking connection parameters in your config file.
About slow reports, i think that much objects can make report slower, i have in my systems reports what generate mor then 60 pages in less of 6 seconds, containing 3 level sub reports with querys, passing parameters end receiving totalizers.

@gamadoleo
Copy link
Contributor Author

JasperPHP\ado\TTransaction::open("dev");

when I refer to changing the patch, I refer to the possibility, for example, of changing the directory where the dev.ini file is, or even some parameter that says that a complete patch of the file is being passed, because as I said, I already have files in another folder ini config files and didn't want to be duplicating the config files

@Rctnet
Copy link
Member

Rctnet commented Jun 12, 2021

Add the solution

if (file_exists($name))

pass full path of file including extension

@gamadoleo
Copy link
Contributor Author

yes..

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

No branches or pull requests

2 participants