Ben bağlantı başarısız olursa, başka bir kullanıcı ile bağlantı kapasitesine sahip bir PHP sınıfı uzanan mysqli oluşturmak çalışıyorum. Muhtemelen kodu ile açıklamak daha kolaydır:
public function __construct() {
$users = new ArrayObject(self::$user);
$passwords = new ArrayObject(self::$pass);
$itUser = $users->getIterator();
$itPass = $passwords->getIterator();
parent::__construct(self::$host, $itUser->current(), $itPass->current(), self::$prefix.self::$db);
while($this->connect_errno && $itUser->valid()){
$itUser->next();
$itPass->next();
$this->change_user($itUser->current(), $itPass->current(), self::$prefix.self::$db);
}
if($this->connect_errno)
throw new Exception("Error", $this->connect_errno);
}
$user and $pass are static variables containing arrays of users and passwords.
If the first user fails to connect, I try with the next one.
Burada sorun, $this->connect_errno ile. Bu mysqli bulamadığını söylüyor.
Buna bir çözüm var mı ya da ben bir fabrika sınıf oluşturmak gerekir?