S
S
Sergei Iamskoi2016-09-27 16:39:29
Yii
Sergei Iamskoi, 2016-09-27 16:39:29

Where does the DataProvider get this behavior from?

There is code, standard, generated by GII, shortened for convenience:

$query = SomeModel::find();
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $query->andWhere(' 1 = 0');
        return $query;

How can the line $query->andWhere('1 = 0'); if $query has already been passed to the constructor in the line above, and the constructor takes a value, not a reference? What's the magic?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vit, 2016-09-27
@syamskoy

query is an object. Roughly speaking - objects are passed by reference in PHP. To be more precise, the variable object in fact is always not the object itself, but a reference to it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question