I have a PHP web application where users, when logged in, have a bunch of different properties associated with them in a MySQL table. I'd like an easy way to access and change (get/set) those properties.
What I want to do is something like this:
$obj = mysql_fetch_object(mysql_query("SELECT * FROM users WHERE userid = '$id'"));
So then, if I want change or access properties, I want to just do something like this:
$obj->password = "newpass";
echo $obj->password;
However, what I have now is that if I want to change the user's password, I have to do this:
mysql_query("UPDATE users SET password = 'newpass' WHERE userid = '$id'");
Is there an easier way to do this that takes up less code?
Thanks for any help in advance.