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의 에러가 있습니다. 다음과 같이

엄격한 표준 경고 읽

적 의도 기본 클래스에서 확장하는 경우. 연결 함수의 선언은 기본 클래스 중 하나와 일치해야합니다 : 귀하의 경우

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) 

.

귀하의 경우 수정은 NULL 당신이 class'es 자신의 디폴트 값을 제공하는 경우, 당신은 단지 첫 번째 매개 변수를 다시 사용하지 않고 간단하다 : 포트와 소켓에없는주의

/* 
* 
*/ 
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