Answer the question
In order to leave comments, you need to log in
Active record empty relatedRecords. Why?
There are 2 models, ProduceInStore and produceHasSupplier. Which are interconnected.
At ProduceInStore
public function getProduceHasSupplier()
{
return $this->hasOne(ProduceHasSupplier::className(), ['code' => 'code']);
}
public function getProduceHasSupplier()
{
return $this->hasOne(ProduceHasSupplier::className(), ['code' => 'code']);
}
$two = (new ProduceInStore())::find()->select([
'lbk_Produce_has_Supplier.idProduce',
'lbk_Produce_inStore.code',
'lbk_Produce_inStore.idSupplier',
'SUM(lbk_Produce_inStore.cnt) as remains'])
->innerJoinWith('produceHasSupplier')
->where('lbk_Produce_inStore.cnt > 0')
->andWhere(['lbk_Produce_has_Supplier.idSupplier' => $access_groups['supplier']])
->andWhere(['lbk_Produce_inStore.idSupplier' => $access_groups['supplier']])
->andWhere(['lbk_Produce_has_Supplier.idProduce' => [1461127, 820793]])
->groupBy('lbk_Produce_has_Supplier.code')
->orderBy('lbk_Produce_has_Supplier.idProduce')
->all();
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