It is best to determine the specifications for the object when creating it and it sounds like your specification of the object doesn't match the pattern you chose.
Generally you should ask yourself, "Do I only need to have a single instance of an object (static) or more than one?"
For this particular instance (connect to and query a database), having an instantiated object for the database object is not advisable unless you need to establish multiple connections to the database/s.
Thusly you have a use-case for an instanced vs static object. Multiple concurrent connections could overload the database, depending on the configuration and how many times a connection is created in a single execution.
So with that in mind there are several OOP design "patterns" for PHP available to aid in the architecture of object/s. See http://www.slideshare.net/RobertGonzalez/object-oriented-design-patterns-for-php-presentation for a good walk through of the more common patterns.
For a working example http://ideone.com/6qxvqx
Note I renamed mysqli to mysqli2 and created a fake class to handle query and added some tracking to the connection and object creation.
<?php
interface iDatabase
{
static public function execute();
public function instantiatedExecute();
}
abstract class database implements iDatabase
{
protected static $conn;
/**
* create an instance of database that uses the same connection across all instances
*/
final public function __construct()
{
self::connect();
}
/**
* Connect to a database if not already connected
*/
final protected static function connect()
{
if (null === self::$conn || false === (self::$conn instanceof mysqli)) {
self::$conn = new mysqli( /* DB info */ );
//add error checking here...
}
return self::$conn;
}
/**
* query database connection
*/
final public function query($query)
{
return self::doQuery($query);
}
/**
* static query database connection
*/
final public static function doQuery($query)
{
//sanitize query here if desired
return self::connect()->query($query);
}
}
class example extends database
{
/**
* example specific static execution
*/
public static function execute($query)
{
self::doQuery($query);
}
/**
* example specific non-static execution
*/
public function instantiatedExecute($query)
{
$this->query($query);
}
}