What's the difference between using all in a query?

So I have the following code which works however I have seen in other examples they use the second example, I was wondering what’s the difference?

Also when I use the second example i get the following error


The "query" property must be an instance of a class that implements the QueryInterface e.g. yii\db\Query or its subclasses.

My Code




        $query = ShopDirectory::find()

        ->where(['LIKE', 'name', $id]);



Second example




        $query = ShopDirectory::find()

        ->where(['LIKE', 'name', $id])

        ->all();



doc

Creates a query




$query = ShopDirectory::find()

        ->where(['LIKE', 'name', $id]);



Returns the results of the query




$models = $query->all();