Harold Somehands
Harold Somehands

Reputation: 5

Yii2 ActiveRecord FindOne() without parameter/s

How to use findOne() in Yii2 without using any parameters? i mean querying like "select top 1 * from table1" or "select * from table1 LIMIT 1" Thanks!

Upvotes: 0

Views: 696

Answers (3)

Arsenii Andreev
Arsenii Andreev

Reputation: 1

Also query $user = User::find()->limit(1)->one(); working faster then $user = User::find()->one();

Upvotes: 0

jithin
jithin

Reputation: 920

query like below

$user = User::find()->one();

Upvotes: 1

Yasin Patel
Yasin Patel

Reputation: 5731

Try This query :

   $model=Users::find()->one(); // your model name

Upvotes: 0

Related Questions