Cannot find documentation for reliable and easy testing of mySQL server. Now I am using the following technique:
@$this->Base = mysqli_init(); @$this->Base->options(MYSQLI_OPT_CONNECT_TIMEOUT, 1); @$this->Base->real_connect($host, $usuario, $senha, $bd);
What will you catch the error with $ this-> Base-> connect_error or $ this-> Base-> connect_errno, it will not be written due to the "@" characters.
You can also use the procedural form:
$Link = mysqli_init(); mysqli_options($Link, MYSQLI_OPT_CONNECT_TIMEOUT, 1); $res = @mysqli_real_connect($host, $usuario, $senha, $bd); if($res) { $E->echop("Connected!!!"); } else { $E->echop("Huston, we got a problem..."); }
Comments and other answers are welcome!
source share