Problem With Constructor Function

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I have a nice, simple mySQL abstraction layer I have worked out in PHP.
Recently I realized on a project that I wanted one of my objects to
automatically clean-up its table on creation.  I had been instantiating a
News object in a page and then calling $newsObj->cleanUp();

So I changed the name of cleanUp() to News().  Seems simple enough right?
Now it should clean up on instantiation...

class News extends DBI {
 var $table = 'news';

 function cleanUp() {
  $data = array(
    "endDate != '0000-00-00'",
    "endDate < NOW()"

However, the constructor function did not have access to the $dbh inherited
from the parent and threw the appropriate errors:

Warning: mysql_query(): Access denied for user: 'talking@localhost' (Using
password: NO) in /yata/yata/yata/classDBI.php on line 211

So my question to you, without much code to go on, is whether anyone knows
why this would be?  When I dumped $this it held what I would expect and was
the Object type it should be.

Thanks for any advice!!


Re: Problem With Constructor Function

Following on from jerrygarciuh's message. . .
Quoted text here. Click to load it
Somewhere in the manual it says you need to explicitly call parent
constructors.  eg parent::ClassFoo() as 1st line in your constructor

PETER FOX Not the same since the deckchair business folded
2 Tees Close, Witham, Essex.
Gravity beer in Essex  <

Re: Problem With Constructor Function

Thanks Peter!!


Quoted text here. Click to load it

Site Timeline