Convert mysql Query
to doctrine Query
language ?
I have done the mysql and run the query in phpmyadmin
and I'm getting returned rows :
select ppp.payperiod_sdesc,ppesa.gross_pay,pptpp.esi_employer_contribution,pptpp.pf_employer_contribution,pplw.employerContribution
from py_process_emp_status_approved AS ppesa
left join py_process_tds_pf_pt AS pptpp on ppesa.ou_code = pptpp.ou_code
left join py_pay_group AS ppg on pptpp.pg_code = ppg.pg_code
left join py_process_labour_welfare AS pplw on ppg.pg_code = pplw.pg_code
left join py_pay_period AS ppp on pplw.payperiod_code = ppp.payperiod_code
left join py_payroll_calendar AS ppc on ppp.paycal_code = ppc.paycal_code
WHERE ppesa.ou_code = 15000
ORDER BY ppesa.ou_code DESC
LIMIT 0,5
please convert the mysql query to doctrine Query language.
You may be able to find more guidance in the docs here: https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/native-sql.html
Have a look at result set mapping. You can also just create a repository function to execute native sql and then call your repo function.
You can then call something like this below: results = getDoctrine()->getManager()->getRepository(Your repo)->repofunction();
If your unsure how to create / call a repository function its covered multiple times in the symfony docs.
Doctrine loads all results then filters down, this is an expensive process you may be best letting sql do the work for you.
Hopefully you have everything you need to get to your end result.