diff --git a/application/third_party/CIUnit/libraries/Fixture.php b/application/third_party/CIUnit/libraries/Fixture.php index a504dd9..5f83eaf 100755 --- a/application/third_party/CIUnit/libraries/Fixture.php +++ b/application/third_party/CIUnit/libraries/Fixture.php @@ -31,7 +31,7 @@ class Fixture { // $fixt is supposed to be an associative array // E.g. outputted by spyc from reading a YAML file - $this->CI->db->simple_query('TRUNCATE TABLE ' . $table . ' CASCADE;'); + $this->truncate($table); if ( ! empty($fixt)) { @@ -49,7 +49,7 @@ class Fixture { $this->_assign_db(); //$Q = TRUE; - $Q = $this->CI->db->simple_query('TRUNCATE TABLE ' . $table . ' CASCADE;'); + $Q = $this->truncate($table); if (!$Q) { echo $this->CI->db->call_function('error', $this->CI->db->conn_id); @@ -78,6 +78,18 @@ class Fixture { } } + private function truncate($table) + { + $sql = 'TRUNCATE TABLE ' . $table; + + if (getenv('DB') !== 'mysql') + { + $sql .= ' CASCADE'; + } + + return $this->CI->db->simple_query($sql); + } + } /* End of file Fixture.php */