diff --git a/drivers/mysql/mysql_driver.php b/drivers/mysql/mysql_driver.php index 8783730..18f99c7 100644 --- a/drivers/mysql/mysql_driver.php +++ b/drivers/mysql/mysql_driver.php @@ -62,6 +62,7 @@ class MySQL extends Abstract_Driver { */ public function truncate($table) { + $table = $this->prefix_table($table); $this->query("TRUNCATE `{$table}`"); } } diff --git a/tests/databases/mysql/MySQLQBTest.php b/tests/databases/mysql/MySQLQBTest.php index e024db3..44c8f27 100644 --- a/tests/databases/mysql/MySQLQBTest.php +++ b/tests/databases/mysql/MySQLQBTest.php @@ -41,6 +41,7 @@ class MySQLQBTest extends QBTest { 'host' => '127.0.0.1', 'port' => '3306', 'database' => 'test', + 'prefix' => 'create_', 'user' => 'root', 'pass' => NULL, 'type' => 'mysql' @@ -73,7 +74,7 @@ class MySQLQBTest extends QBTest { array ( 'id' => '1', 'select_type' => 'SIMPLE', - 'table' => 'test', + 'table' => 'create_test', 'type' => 'range', 'possible_keys' => 'PRIMARY', 'key' => 'PRIMARY', diff --git a/tests/databases/mysql/MySQLTest.php b/tests/databases/mysql/MySQLTest.php index 72ad121..5b1ce67 100644 --- a/tests/databases/mysql/MySQLTest.php +++ b/tests/databases/mysql/MySQLTest.php @@ -43,6 +43,8 @@ class MySQLTest extends DBTest { { $this->db = new \Query\Driver\MySQL('host=127.0.0.1;port=3306;dbname=test', 'root'); } + + $this->db->table_prefix = 'create_'; } // -------------------------------------------------------------------------- @@ -95,7 +97,7 @@ class MySQLTest extends DBTest { //Check $dbs = $this->db->get_tables(); - $this->assertTrue(in_array('test', $dbs)); + $this->assertTrue(in_array('create_test', $dbs)); } @@ -112,7 +114,7 @@ class MySQLTest extends DBTest { public function testPreparedStatements() { $sql = <<db->prepare_query($sql, array(1,"boogers", "Gross")); @@ -128,7 +130,7 @@ SQL; public function testBadPreparedStatement() { $sql = <<db->prepare_execute($sql, array( @@ -164,7 +166,7 @@ SQL; { $res = $this->db->beginTransaction(); - $sql = 'INSERT INTO `test` (`id`, `key`, `val`) VALUES (10, 12, 14)'; + $sql = 'INSERT INTO `create_test` (`id`, `key`, `val`) VALUES (10, 12, 14)'; $this->db->query($sql); $res = $this->db->commit(); @@ -177,7 +179,7 @@ SQL; { $res = $this->db->beginTransaction(); - $sql = 'INSERT INTO `test` (`id`, `key`, `val`) VALUES (182, 96, 43)'; + $sql = 'INSERT INTO `create_test` (`id`, `key`, `val`) VALUES (182, 96, 43)'; $this->db->query($sql); $res = $this->db->rollback(); diff --git a/tests/databases/pgsql/PgSQLTest.php b/tests/databases/pgsql/PgSQLTest.php index 90b3a68..039f5e9 100644 --- a/tests/databases/pgsql/PgSQLTest.php +++ b/tests/databases/pgsql/PgSQLTest.php @@ -37,12 +37,13 @@ class PgTest extends DBTest { $params = $params->pgsql; $this->db = new $class("pgsql:dbname={$params->database}", $params->user, $params->pass); - $this->db->table_prefix = $params->prefix; } elseif (($var = getenv('CI'))) { $this->db = new $class('host=127.0.0.1;port=5432;dbname=test', 'postgres'); } + + $this->db->table_prefix = 'create_'; } // -------------------------------------------------------------------------- diff --git a/tests/databases/sqlite/SqliteTest.php b/tests/databases/sqlite/SqliteTest.php index 39b92fb..58b70f2 100644 --- a/tests/databases/sqlite/SqliteTest.php +++ b/tests/databases/sqlite/SqliteTest.php @@ -25,6 +25,7 @@ class SQLiteTest extends DBTest { // Set up in the bootstrap to mitigate // connection locking issues $this->db = Query('test_sqlite'); + $this->db->table_prefix = 'create_'; } // --------------------------------------------------------------------------