I 'm trying to do the update general query . A function that receives the table , and the field and updated. The problem is that the query I have is generating an error.
public function update($table,$set,$where){
$sql="UPDATE $table SET $set WHERE $where";
if($result=$this->mysqli->query($sql)){
return $this->mysqli->insert_id;
}
else{
throw new Exception("Error".$this->mysqli->error);
}
}
The problem is that when I call the function generates an error:
$table='mytable';
$set='column=$mydata+5';
$where="id=1";
$this->db->update($table,$set,$where);
Uncaught exception 'Exception' with message 'ErrorUnknown column '$mydata' in 'field list''