Hi guys.
I have a very different perspective on this topic. Over the years Ive read though tons and tons of **** code. A lot of which written in OO by people who really didn't know what they were doing.
The fact is, this class offers 2 features. AddMember and CheckUserExists.
In the real world, unless you know what you are doing, you are better off just dealing with well written, highly testing, independant and debuged functions.
But thats my view. I love OOP as much as the next guy, but at the end of the day, you need "bang for buck".
Solid coded functions win over uncooked over engineered OO classes.
below is my view of how this code should have been written (untested).
/**
** Adds a new member to the members table.
**/
function AddMember($uname, $pass, $email)
{
$uname = mysql_real_escape_string($uname);
$pass = md5($pass);
$email = mysql_real_escape_string($email);
$regtime = time();
return mysql_query("
INSERT INTO membersTable (uname, pass, email, regtime)
VALUES ('$uname', '$pass', '$email', '$regtime')";
}
/**
** Checks if username exists. Returns true if it does.
**/
function CheckUserExists($uname)
{
return
mysql_numrows(
mysql_query("SELECT * FROM membersTable where uname ='$uname'")) > 0;
}