public static function hostConnect($database = "{database}") { //---------------------------------------------------------- //init var //---------------------------------------------------------- $class = "GlobalMas"; //---------------------------------------------------------- $chk = self::constCHK($database); $mysqli = NULL; //---------------------------------------------------------- if (isset($chk['bool']) && !$chk['bool']) { return $chk; } else { $database = $chk; } //---------------------------------------------------------- if (is_null(GlobalMas::$mysqli) || !($chk = GlobalMas::$mysqli->select_db($database))) { //------------------------------------------------------ if (is_null($mysqli)) { $mysqli = new mysqli(ClassUtil::getStaticVal($class, "host")['constant'], ClassUtil::getStaticVal($class, "user")["constant"], ClassUtil::getStaticVal($class, "pass")['constant']); } //------------------------------------------------------ if ($mysqli->connect_error != null || $mysqli->host_info == null) { $chk = array("result" => $mysqli, "error" => true, "bool" => false, "host_info" => !GlobalMas::$debug ? NULL : $mysqli->host_info, "message" => $mysqli->connect_error); if (!GlobalMas::$debug) { $chk["loginInfo"] = array("host" => ClassUtil::getStaticVal($class, "host")['constant']); } return $chk; } //------------------------------------------------------ GlobalMas::$mysqli = $mysqli; } //---------------------------------------------------------- GlobalMas::$mysqli->select_db($database); //---------------------------------------------------------- if (GlobalMas::$mysqli->error != null) { $chk = array("result" => GlobalMas::$mysqli, "error" => true, "bool" => false, "message" => GlobalMas::$mysqli->error); if (!GlobalMas::$debug) { $chk["loginInfo"] = array("host" => ClassUtil::getStaticVal($class, "host")['constant']); } return $chk; } //---------------------------------------------------------- return GlobalMas::$mysqli; }