Good for all. I have a table in which there is a column fio and a line Vasya Pupkin Explain why the code

$model = Orders::find() ->where(['like','fio','Pup']) ->one(); 

Gives me this Vasya, and

 $model = Orders::findOne(['like','fio','Pup']); 

Issues nothing.

    2 answers 2

    Because findOne doesn't work like this, this is what the documentation says:

    Returns is a single active record of the column values.

    If an array is passed to this method, then both the field and the value are passed to the key — the value in this field searches for the exact match. So in your case, only 1 option.

      When a condition is passed to the findOne () method as a non-associated array, this condition will be applied to the primary key of your table.

      http://www.yiiframework.com/doc-2.0/yii-db-baseactiverecord.html#findOne()-detail

      https://github.com/yiisoft/yii2/blob/master/framework/db/BaseActiveRecord.php#L105