Answer the question
In order to leave comments, you need to log in
How to rewrite sql query in ActiveQuery?
Good afternoon. There is a not quite simple sql query that needs to be rewritten in ActiveQuery in order to avoid possible sql injections. The actual request:
SELECT
`policy`.`id`,
`operator_id` as 'id оператора',
`email оператора`,
`ФИО`,
`av_user`.`subdivision` as 'Подразделение от АВ',
`av_user`.`curator` as 'Куратор от АВ',
`policy`.`payed_date` as 'Дата оплаты',
`policy`.`cost` as 'СП',
`policy`.`user_remuneration` as 'КВ'
FROM (select *,
replace(JSON_EXTRACT(`parameters`, '$.users.operator.email'), '"', '') as `email оператора`,
replace(JSON_EXTRACT(`parameters`, '$.users.operator.full_name'), '"', '') as `ФИО`,
JSON_EXTRACT(`parameters`, '$.users.operator.id') as `operator_id`
FROM `partner__data`
) as tt
LEFT JOIN `av_user` on `av_user`.`id` = tt.`operator_id`
LEFT JOIN `policy` on `policy`.`id` = tt.`policy_id`
WHERE LOWER(`ФИО`) like LOWER('%$name%')
AND policy.`payed_date` between '$min' and '$max'
GROUP BY policy.`payed_date`
ORDER BY policy.`payed_date`
FROM (select *,
replace(JSON_EXTRACT(`parameters`, '$.users.operator.email'), '"', '') as `email оператора`,
replace(JSON_EXTRACT(`parameters`, '$.users.operator.full_name'), '"', '') as `ФИО`,
JSON_EXTRACT(`parameters`, '$.users.operator.id') as `operator_id`
FROM `partner__data`
) as tt
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question