Hi,
Im trying to perform a query using Adodb within a class.
The class is a search function and from within the process function within the class I'm trying to run this code

$results = $userdb->Execute($this->query);

But the error I'm getting is:
Fatal error: Call to a member function Execute() on a non-object in \search.php on line 128

The adodb class has been declared and called within an init.php which is included into the right place and all the other files have been included accordingly.

I'm guessing the error is cause by limits with classes that are preventing me from accessing another classes functions. But is there a way around this to allow it to work and access the adodb class?

Hope I made sense. I can try and explain things better if necessary.

Thaks in advance
Mike

    You should give your class a reference to your database object.

    i.e.

    class myClass{
      public $db;
      public function __construct(){
        //maybe do something
      }
    
      public function setDB($db){
       $this->db = $db;
      }
    }
    
    $db = //mysql connect and jazz
    $class = new myClass();
    $class->setDB($db);
    $class->db->Execute('SELECT something FROM table');
    
      Write a Reply...