2012-05-03 2 views
0

私はPHP 5.4に私のウェブサーバーのアップグレードを持っていたとmysqliの中に組み込まれてから延びている私のデータベースクラスを使用して、私のサイト上のエラーを取得しています。エラーが....私のクラスの最後の行に、すべてが正常に動作しているエラーメッセージにもかかわらず、カスタムmysqliクラスにPHP 5.4でエラーがありますか?

あるエラーメッセージ:

Strict Standards: Declaration of yamiko_mysqli::connect() should be compatible with mysqli::connect($host = NULL, $user = NULL, $password = NULL, $database = NULL, $port = NULL, $socket = NULL) in /home/markwe6/public_html/_php/yamiko_mysqli.php on line 109 

とクラスがある:

class Yamiko_mysqli extends mysqli 
{ 
    public $host='localhost'; 
    public $user='markwe6_yamiko'; 
    public $pass='1chrysanthemum!'; 
    public $db='markwe6_cp'; 
    public $result=NULL;#stores most recent result 

    /* 
    * 
    */ 
    public function __construct($auto=TRUE) 
    { 
     if($auto) 
     { 
      return $this->connect(); 
     }else 
     { 
      return TRUE; 
     } 
    } 

    /* 
    * 
    */ 
    public function connect($auto=TRUE, $user=NULL, $pass=NULL, $host=NULL, $db=NULL) 
    { 
     if($auto) 
     { 
      parent::__construct($this->host, $this->user, $this->pass, $this->db); 
      return $this->check_error(); 
     }else 
     { 
      parent::__construct($host, $user, $pass, $db); 
      return $this->check_error(); 
     } 
    } 

    /* 
    * 
    */ 
    public function query($sql) 
    { 
     $result=parent::query($sql); 
     if($this->check_error()) 
      return FALSE; 
     $this->result=$result; 
     return $result; 
    } 

    /* 
    * 
    */ 
    private function check_error() 
    { 
     if($this->connect_error!=NULL) 
     { 
      $GLOBALS['yamiko']->set_error('yamiko_myslqi connection error: '.$this->connect_error); 
      return FALSE; 
     }elseif ($this->error!=NULL) 
     { 
      $GLOBALS['yamiko']->set_error('yamiko_myslqi error: '.$this->error); 
      return FALSE; 
     } 
    } 
}#this is line 109....-_- 
+0

エラーメッセージのどの部分を理解していませんか? - または - あなたの質問は何ですか? – hakre

+0

私はこのエラーを全く理解していません...クラスはうまく動いています – Yamiko

答えて

3

カスタムmysqliのクラスは、PHP 5.4でエラーが発生しましたか?

いや、ないエラーが、厳格な標準の警告。警告をエラーとみなした場合は、カスタムmysqliクラスにはPHP 5.4のエラーがあります。次のように

厳格な標準警告が読み:

あなたが意図基本クラスから拡張する場合。 connect関数の宣言は、基本クラスの1つに一致する必要があります:あなたのケースでは

mysqli::connect($host = NULL, $user = NULL, $password = NULL, $database = NULL, $port = NULL, $socket = NULL) 

をそうでない:あなたが見ることができるように、両者が異なるパラメータを持っている

Yamiko_mysqli::connect($auto=TRUE, $user=NULL, $pass=NULL, $host=NULL, $db=NULL) 

あなたのケースでは修正プログラムは、あなたがclass'esに自身のデフォルト値を提供NULL場合はちょうど、最初のパラメータを再使用し、かなり簡単です:

/* 
* 
*/ 
public function connect($host = NULL, $user = NULL, $password = NULL, $database = NULL, $port = NULL, $socket = NULL) 
{ 
    if($host === NULL) 
    { 
     parent::__construct($this->host, $this->user, $this->pass, $this->db); 
     return $this->check_error(); 
    }else 
    { 
     parent::__construct($host, $user, $password , $database, $port, $socket); 
     return $this->check_error(); 
    } 
} 

は、ポートとソケットがで欠落していることに注意してくださいあなたのデフォルト設定。

+0

警告が表示されないようにする方法はありますか? – Yamiko

+0

表示していますか?おそらく['display_errors'](http://php.net/display_errors)を無効にしてください。それ以外の場合は、同じパラメータを使用するか、mysqliから継承しないでください。私も答えを更新しましたので、より多くの情報が含まれています。 – hakre

+0

@yamikoWebs:ちょうどあなたが必要とするものを見て、簡単な修正を加えました。 – hakre

関連する問題