L
L
Leopandro2016-01-22 17:38:11
Yii
Leopandro, 2016-01-22 17:38:11

How to pass $query date to provider?

I pass the date to the provider the Query object as it is written in the documentation, it says to me that the type requires an instance of the Query class, but how do I pass the class instance if, after creating the Query object, I create an array from the result of the sql query?

$query = (new Query())
                ->select($columns)
                ->from([BaseMaterial::tableName(), $table_name])
                ->all();
            
            $dataProvider = new ActiveDataProvider([
                'query' => $query
            ]);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shamyyl, 2016-01-22
@shamyyl

You are not passing query.
It would be correct like this:

$query = (new Query())
                ->select($columns)
                ->from([BaseMaterial::tableName(), $table_name]);
            
            $dataProvider = new ActiveDataProvider([
                'query' => $query
            ]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question