Answer the question
In order to leave comments, you need to log in
How to add distinct to a query in Bitrix ORM?
Hello!
There is a table described in Entities\Marketing\PostingTmpTable
. It stores intermediate data on mailings from the site. The table has about 500,000 entries. Collected by an additional script.
The main field used is EMAIL. There is a connection with other tables
through
it
. \PostingTable has a MAILING_ID field - the id of the distribution group by which filtering is done.
It turns out, something like this request:
$query = (new \Bitrix\Main\Entity\Query(\Entities\Marketing\PostingTmpTable::getEntity()))
->registerRuntimeField('PROPERTY', [
'data_type' => $hlBlockEntity,
'reference' => [
'=this.EMAIL' => 'ref.UF_EMAIL'
]
])
->registerRuntimeField('RECIPIENT', [
'data_type' => '\Bitrix\Sender\PostingRecipientTable',
'reference' => [
'=this.EMAIL' => 'ref.EMAIL',
],
])
->registerRuntimeField('POSTING', [
'data_type' => '\Bitrix\Sender\PostingTable',
'reference' => [
'=this.RECIPIENT.POSTING_ID' => 'ref.ID',
]
])
->where('POSTING.MAILING_ID', 6)
->setSelect(/* сюда ставлю собираемый массив селектов, к делу не относится*/)
;
Answer the question
In order to leave comments, you need to log in
In general, the documentation has an expression field
https://dev.1c-bitrix.ru/learning/course/index.php...
new Entity\ExpressionField('DISTINCT_ID',
'DISTINCT %s', array('ID')
)
I think it's in select
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question