Cant find the .find method inside the class

So playing with a yii2 project I encounted the following thing.

$var = Product::find().where();

The class Product is extended with the ActiveRecord class, but the class Product does not contain a method called find.

Could not find any good info about this.

Hi,

You basically named the reason already.

"Product extends ActiveRecord"

Means:

Everything available in "ActiveRecord" is also available in your "Product".

So take a look at:

vendor\yiisoft\yii2\db\ActiveRecord.php

and there on line 269 you will find:

public static function find()

;)

If you want to know more about the topic, just google:

“php class inheritance” and read. ;)

Best Regards

I use this method a lot, usually typed like:




$var = Product::find()->where(['someAttribute'=>$someVariable])->all();



I don’t think it would work with the period after find() like you have it there if that is indeed how you have it in your code.