its shows that syntax error in sql statement with this message database query failed : ... use right syntax near " at line 1 however i can't find one plz help
public function update(){
global $database;
$attributes = $this->attributes();
$attribute_pairs = array();
foreach ($attributes as $key => $value) {
# code...
$attribute_pairs[] = "$key = $value";
}
$sql = "UPDATE ".self::$table_name." SET ";
$sql .= join(", ", $attribute_pairs);
$sql .= " WHERE id=".$this->id;
$database->query($sql);
return ($database->affected_rows() == 1) ? true : false;
}