예제 #1
0
 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;
 }
예제 #2
0
 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();
 }