I'm getting an error with the code below. Here is the error message I get:Notice: Undefined variable: userDAO in C:\wamp\www\Projetv0.2\Model_User.php on line 15
and thenFatal error: Call to a member function checkRecordExists() on a non-object in C:\wamp\www\Projetv0.2\Model_User.php on line 15

The relevant code is below. What I try to do with the code is have a unique class (DAO_DBrecord) to access several tables in a db. In the case below, I want to access my users table. To do that I have created a specific static function createUserDAO inside the DAO_DBrecord class that calls the constructor with the right table name, users. However, it doesn't work, and I can't figure why.

1 Answer
1

That's not a problem with the static function. The problem is that PHP doesn't have an implicit $this. When you're referring to the member variable within the class (as you are in userInfoExists), you have to say $this->userDAO rather than just $userDAO.

Of course, all this assumes that the DAO_DBrecord class has or inherits a checkRecordExists function. If it doesn't, you're going to have other problems.