I am trying to set a function that will dynamically update an object attribute in the db w/o updating the whole object.
$sql = "UPDATE " . self::$table_name . " SET ";
$sql .= "$attribute = '" . eval("\$this->$attribute;") . "'";
$sql .= " WHERE ...";
I cant seem to get this eval("\$this->$attribute;") to produce the object attribute value. There is a value in the attribute and it is a public attribute.
Thanks
$attribute is a function var that will contain a string like 'address_id' so I want UPDATE table_name SET address_id = '11' WHERE user_id='1' This is a simple example of it
eval()it? Surely$this->attributewill suffice?eval(), you're making a mistake.eval()is almost always unnecessary. It certainly doesn't seem necessary here.