Answer the question
In order to leave comments, you need to log in
Why am I getting an error?
here is the code:
$query = Product::find()->joinWith('salonProduct')->select([
'*',
new \yii\db\Expression('IF(salon_product.id IS NULL, 1, 0) AS salon_product_id')
]);
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSize' => 24,
],
'sort' => [
'defaultOrder' => [
'salon_product_id' => SORT_ASC
]
],
]);
public function getSalonProduct(){
return $this->hasOne(SalonProduct::className(),['product_id'=>'id']);
}
public function getOrders($recalculate = false)
{
$attributeOrders = $this->getAttributeOrders($recalculate);
$orders = [];
foreach ($attributeOrders as $attribute => $direction) {
$definition = $this->attributes[$attribute];
$columns = $definition[$direction === SORT_ASC ? 'asc' : 'desc'];
foreach ($columns as $name => $dir) {
$orders[$name] = $dir;
}
}
return $orders;
}
Answer the question
In order to leave comments, you need to log in
I can't figure out what has changed, but this is how it works:
As a matter of fact painted default for joinWith.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question