mem0ri Posted January 27, 2008 Share Posted January 27, 2008 I'm attempting to run a singleton-pattern on my MySQL Database Class and I'm running into problems referencing over to it...example: On the login page itself: $user = new User; // loading through the __autoload function and does work //...IRRELEVANT PHP CODE... $validate = $user->login($_POST['email'], $_POST['password']); Within the User->login function: public function login($email, $pass) { echo("INSIDE LOGIN"); $sql = MySQL::getinstance(); die("CREATED MYSQL INSTANCE"); //...ADDITIONAL IRRELEVANT CODE... Within the MySQL::getinstance(); function: public static function getinstance() { if(self::$instance == NULL) self::$instance = new MySQL; return self::$instance; } The "echo" and "die" within the User->login() function are just for debugging. I will always reach the echo, but never reach the die...therefore, the problem is definitely in the MySQL::getinstance() line... ...thing is...I can't figure out what's wrong with the structure? The MySQL class and User class are in separate files...but that shouldn't matter with the __autoload function, correct? Quote Link to comment https://forums.phpfreaks.com/topic/88093-solved-singleton-patterning-challenge/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.