L
L
LightSid2017-06-09 18:07:16
Yii
LightSid, 2017-06-09 18:07:16

How to get ENUM index in Yii2?

Please tell me how to get the ENUM index
Is there a field in the table where:


[
'0' => 'Large',
'1' => 'Medium',
'2' => 'Small'
]

If you just remove from the base
$item->size;

then it will output exactly the word, but you need to get its number

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2017-06-09
@webinar

Do you have an array in 1 table field?

M
Maxim Fedorov, 2017-06-12
@qonand

Please tell me how to get the ENUM index

The ENUM index can only be obtained at the database level, for example, for MySQL, this can be done like this: Another question is why do you need this index? ENUM is intended just to avoid working with indexes. As Maksim Timofeev said , perhaps it is really not appropriate to use ENUM in your task and it is better to use an int data type?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question