Problem update model

Hi, i have the following problem:
the modem id is an alphanumeric code.
When I update the model, with $model->save(), the query looks for id = code looked for.
I wish I could convert this line to id like searched code.
Example:
UPDATE deposito SET Negozio=Negozio - 1 WHERE Id_Deposito = 80117a79325821
convert in
UPDATE deposito SET Negozio=Negozio - 1 WHERE Id_Deposito like ‘80117a79325821’

How did you define Id_Deposito in your model? That will automatically drive Yii to handle the data type properly.

1 Like

Hi,
Id_Deposito primary key varchar(20) utf8mb4_general_ci

I configured it this way since it is a unique code of a product.
When I search for the product using like it finds it.
When I go to update the changes with save() sometimes it doesn’t find the product and therefore it doesn’t even give me the error of how to save it

No, not in the database, but in your Yii model

[[‘Id_Deposito’], ‘string’],

[[‘Id_Deposito’], ‘string’, ‘max’ => 20],

1 Like

Thanks in advance
yes I set it:
[ [ ‘Id_Deposito’ ], ‘string’, ‘max’ => 20],