$table->show(); } catch (\Exception $e) { echo $e->getMessage(); } // */ // // example 2 using PDO // //* try { $table = new \Cli\Table(); $db = new \PDO('mysql:host=localhost;dbname=test', 'H675X16em4', 'XOc1pu3AcAnINA2eKEY4ruRO8i8iXI'); $db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $stmt = $db->prepare('SELECT * FROM `table`'); $stmt->execute(); $table->importFromPDO($stmt); $table->show(); } catch (\Exception $e) { echo $e->getMessage(); } // */ // // example 2 using mysqli // //* try { $table = new \Cli\Table(); $db = new \mysqli('localhost', 'H675X16em4', 'XOc1pu3AcAnINA2eKEY4ruRO8i8iXI', 'test'); if ($db->connect_errno) { throw new \Exception("Failed to connect to MySQL: (" . $db->connect_errno . ") " . $db->connect_error); }