I am trying to create a Class that will be using a external api and wpdb class however i am having issues already in the try catch block please confirm the below is correct:
<?php
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php' );
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-includes/wp-db.php' );
class LoLApi
{
private $database;
public function __construct()
{
try {
$this->database = new wpdb('user', 'pass', 'table', '127.0.0.1');
$this->database->show_errors();
} catch (Exception $e) {
return $e->getMessage();
}
}
}
?>
in the other page:
<?php
session_start();
require 'includes/lolapi.class.php';
$api = new LoLApi;
exit();
?>