Answer the question
In order to leave comments, you need to log in
How to get the last value of a field from a model?
there is a model, a table (as you like), here is the name of the fields - 'id','name','id_operation'
id
autoincrement id_operation
- can be the same for several records.
I need to get the last value id_operation
, given that the numbering is ascending from zero.
Answer the question
In order to leave comments, you need to log in
I need to get the last value of id_operation, given that the numbering is ascending from zero.
$model = Model::find()->orderBy('id_operation DESC')->one();
echo $model->id_operation;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question