M
M
Maxim Timofeev2016-06-18 19:07:39
MySQL
Maxim Timofeev, 2016-06-18 19:07:39

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
                ]
            ],
        ]);

connection
public function getSalonProduct(){
        return $this->hasOne(SalonProduct::className(),['product_id'=>'id']);
    }

error:
PHP Warning - yii\base\ErrorException
Invalid argument supplied for foreach() specifically here: foreach ($columns as $name => $dir)
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

1 answer(s)
M
Maxim Timofeev, 2016-06-19
@webinar

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 question

Ask a Question

731 491 924 answers to any question