Answer the question
In order to leave comments, you need to log in
Getting value from db yii2?
Greetings.
At the moment, I get the id value from the database like this:
$id = UserSubscription::find()->where(['user' => 16])->one();
$id = $id->id;
$id = UserSubscription::find()->select(['id'])->where(['user' => 16])->one();
Answer the question
In order to leave comments, you need to log in
There is a scalar method for this, that is, it will be like this:
UserSubscription::find()->select(['id'])->where(['user' => 16])->scalar()
Goodnight.
Like so
$count = UserSubscription::find()
->where(['user' => 16])
->count();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question