i've been searching for an approach to an object oriented user system but I couldn't find any tutorial that answers my questions. I really don't care about the code stuff, I can do that later, but the logic of the OOP is really killing me (oh, I'm new to OOP, I forgot to mention it).
If I have a mysql db with users, and a php file with two classes, a dbmanager and a user class, is ok to use dbmanager's methods inside the user class?
If not, how should I do to make the user class and the db class interact with each other?
Thanks
---EDIT---
Would this approach be right? What's the benefits of using, for example, extended classes?
class db{
function checkUser($login, $password){
$password = sha1(md5($password)); //encrypt password
$query = "SELECT * FROM users WHERE (login='$login' OR email='$login')";
$result = mysql_query($query);
if ($user = mysql_fetch_assoc($result)) {
if ($user["password"] == $password) {
//there's a user class somwhere else
$checkeduser = new user($user);
return $checkeduser;
} else return true; //bad password
} else return false; //user not registered
}
$user = $dbconnection->checkUser($login, $password); //encrypted password
if(is_object($user)) { //if logs in
$_SESSION["user"] = serialize($user);
header("Location:index.php"); //go to home
}