-2

php oop problem extends mysqli override method?

i have a problem with my class extends mysqli that i cannot override query method

that error shows up

( ! ) Strict standards: Declaration of database::query() should be compatible with mysqli::query($query) in E:\LOCALHOST\www\basket\library\database.class.php on line 92

here is a part of the code

class database extends mysqli
{

    protected $config;

    protected static $instance;

    protected $query;

    protected $where;

    protected $limit;




    public function __construct($config)
    {
        $this->config   = $config;

        self::$instance = parent::__construct($config['hostname'],$config['username'],$config['password'],$config['database'],$config['port']);

    }

    public static function getInstance() {

        if(!self::$instance)
        {
            self::$instance = new self();
        }

        return self::$instance;

    }
    public function query()
    {

    }
  • It means that your declaration of `query()` must be compatible with its parent `query($query)`. Try adding `public function query($query)` Also, you may want to read [Who needs singletons](http://stackoverflow.com/a/4596323/1607098) – Touki Sep 02 '13 at 14:54
  • possible duplicate of [Declaration of Methods should be Compatible with Parent Methods in PHP](http://stackoverflow.com/questions/3115388/declaration-of-methods-should-be-compatible-with-parent-methods-in-php) – DCoder Sep 02 '13 at 14:56
  • @touki i know sir that the method wants me to pass "$query" parameter but i want to pass more that one "$query" parameter what can i do – Ahmed Rewesh Sep 02 '13 at 15:12

1 Answers1

0

See the documentation of mysqli::query():

mixed mysqli::query ( string $query [, int $resultmode = MYSQLI_STORE_RESULT ] )

Your overriding method needs to take the same arguments.

Barmar
  • 741,623
  • 53
  • 500
  • 612