Field String saves as an integer php objects and mysql


I have a update that is done in the following way.

 public function update_donante($tabla,$caso,$link,$campo,$tipodonante){


$this->sqll= "UPDATE ".$this->tabla." SET ".$this->campo."='".$this->tipodonante."' WHERE idCaso="."'".$this->caso."'";


this is sent with a function ajax , and return with a die(); to get the query per screen and see what comes out.

the query is as follows


UPDATE patient_data SET donor_type = 'Donor' WHERE idCaso = '159'

It is well written but when I generate it directly by the mysql it is ok updates the field, but when I do it from the code it updates the field to 1.

The field is in nvarchar 200 that is more than I need and the variables are correct.

Can someone help me with this?

asked by Oscar David 15.11.2018 в 11:26

1 answer


Okay, and I realized what was happening, the process was correct but before that I had a conditional

switch ($ method) {         case 'update':





Then I did not have it closed correctly, what happened? when leaving, I was missing the else (to see if it was true or not), which passed and overwritten the value of a numeric field since it renamed the field.

answered by 15.11.2018 в 11:54