/** * Create and test connection and existence of destination table (but not it structure) * * @param String $dest table name in MySQL db * @param \SULB_OAS\ConfigParser $config Configuration * @return boolean true * @throws Exception if connection error * @throws Exception if table does not exist */ public static function connect($dest, ConfigParser $config) { self::$connection = new \mysqli($config->getDbHost(), $config->getDbUser(), $config->getDbPassword(), $config->getDbName(), $config->getDbPort(), $config->getDbSocket()); if (self::$connection->connect_error) { throw new Exception('Connect Error (' . self::$connection->connect_errno . ') ' . self::$connection->connect_error); } self::$destination = $dest; if ($res = self::$connection->query('show tables like ' . self::$destination) && $res->num_rows != 1) { throw new Exception('Table ' . self::$destination . ' is missing in DB ' . $config->getDbName()); } return true; }