General Code Refactoring

I noticed that there was a mix between Object Oriented and Procedural style in the class so I made it all Object Oriented to prevent confusion.

I added 3 private attributes to the top of the class; $_connection, $_last_query and $_info. In the constructor as you can see the $_info attribute is an associative array that handles all the database credentials (I added the database port). I also did the error checking when the connection is established, instead of putting it into a new method.

This change means that you enter your information as arguments to the constructor like so,

$login = new login('localhost', 'username', 'password', 'database', 'port', 'prefix');

Everything else is the same. I did do some shuffling around and general refactoring of the code. Since I made these changes I have tested creating a user account, and it was successful. I haven't however tested any other methods but they should work.

I also added a new argument to the retrieveUser method which determines whether the user retrieval is for checking if the account exists or whether to return a record from the database.