View Single Post
Old 01-27-2012, 06:01 PM   #1 (permalink)
captainmerton
The Acquainted
 
captainmerton's Avatar
 
Join Date: May 2009
Posts: 178
Thanks: 9
captainmerton is on a distinguished road
Default Static Method Issue

Hi i hav extended the mysqli class and want to add some further functionality to the static method i have created for creation of the database access object (see below). I want to add some further functionality however to read in the current website url and then point to a different database based on the url. When i try to add code into the static method looking for certain characters in the $_SERVER['HTTP_HOST'] global variable i get error messages:

Call to a member function query() on a non-object

I assume i cant call global verianbles in a static method perhaps? Any guidance on what th issue is and how i might solve?

PHP Code:
        public static function getInstance() {

            if (empty (
self::$instance)) {
                
self::$instance = new DataLayer(DB_HOSTDB_USERDB_PASSDB_DATABASE) or die("Cannot connect to MySQL server!");
            }

            return 
self::$instance;

        } 
captainmerton is offline  
Reply With Quote