Field String saves as an integer php objects and mysql

0

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

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

            $this->tabla=$tabla;
            $this->caso=$caso;
            $this->con=$link;
            $this->campo=$campo;
            $this->tipodonante=$tipodonante;

$this->sqll= "UPDATE ".$this->tabla." SET ".$this->campo."='".$this->tipodonante."' WHERE idCaso="."'".$this->caso."'";
            //die($this->sqll);
            $this->resull=mysql_query($this->sqll,$this->con);

}

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
source

1 answer

0

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

switch ($ method) {         case 'update':

        if($tipodonante!=""){
            $consultas->update($tabla,$id_caso,$link,$campo,$valor);

            $campo="tipo_donante";

            $consultas->update_donante($tabla,$id_caso,$link,$campo,$tipodonante);

        }else{
            $consultas->update($tabla,$id_caso,$link,$campo,$valor);
        }
        break;

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