public final function getConnection() { if ($this->conn === null) { try { if (self::$pdo == null) { self::$pdo = new PDO('mysql:host=' . DATABASE_HOST . ';dbname=' . DATABASE_NAME, DATABASE_USERNAME, DATABASE_PASSWORD); } $this->conn = $this->createDefaultDBConnection(self::$pdo, DATABASE_NAME); } catch (PDOException $e) { print_r($e->getMessage()); } } return $this->conn; }
public function tearDown() { $conn = $this->getConnection(); $pdo = $conn->getConnection(); $allTables = $this->getDataSet()->getTableNames(); foreach ($allTables as $table) { if ($table == 'test_pdo') { $pdo->exec("DROP TABLE IF EXISTS `{$table}`;"); } } $conn->close(); parent::tearDown(); }