Shifting from procedural to OOP, so say I'm going to delete a user, I used to have something like:
if(!empty($_GET['d_uid'])){
$uid = mysql_real_escape_string($_GET['d_uid']);
if(deleteUser($uid)){
// success
} else {
// fail
}
}
But now, since I have written a class to hold all the user functions (class name User), is the best was to accomplish this to instantiate the user class in order to access a function for deleting the user?
Example:
if(!empty($_GET['d_uid'])){
$uid = mysql_real_escape_string($_GET['d_uid']);
$user = new User($uid);
if($user->deleteUser()){
// success
} else {
// fail
}
}
or perhaps use a scope resolution operator?:
if(!empty($_GET['d_uid'])){
$uid = mysql_real_escape_string($_GET['d_uid']);
if(User::deleteUser($uid)){
// success
} else {
// fail
}
}