Tweak fixture library to work with mysql and postgres
This commit is contained in:
parent
8400ee2a5c
commit
38d62f331c
@ -31,7 +31,7 @@ class Fixture {
|
|||||||
|
|
||||||
// $fixt is supposed to be an associative array
|
// $fixt is supposed to be an associative array
|
||||||
// E.g. outputted by spyc from reading a YAML file
|
// 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))
|
if ( ! empty($fixt))
|
||||||
{
|
{
|
||||||
@ -49,7 +49,7 @@ class Fixture {
|
|||||||
$this->_assign_db();
|
$this->_assign_db();
|
||||||
|
|
||||||
//$Q = TRUE;
|
//$Q = TRUE;
|
||||||
$Q = $this->CI->db->simple_query('TRUNCATE TABLE ' . $table . ' CASCADE;');
|
$Q = $this->truncate($table);
|
||||||
|
|
||||||
if (!$Q) {
|
if (!$Q) {
|
||||||
echo $this->CI->db->call_function('error', $this->CI->db->conn_id);
|
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 */
|
/* End of file Fixture.php */
|
||||||
|
Loading…
Reference in New Issue
Block a user