Commit 38d62f33 by Timothy J Warren

Tweak fixture library to work with mysql and postgres

parent 8400ee2a
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment