• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
db_forge's drop_table() does not clear the dropped table from the db data_cache

When using the dbforge to drop a table(dbdriver=mysql) it is not possible to correctly check the existence of a table after it is dropped.

class Simple_db_model extends Model
    function __construct() {


    function setup_db($drop=FALSE) {

        if ($drop === TRUE) {

        // the db class has the table cached so testing
        // for it's existence here will incorrectly confirm
        // that the table does exist
        if (!$this->db->table_exists('my_table')) {
            // ... create table, etc.

As a workaround I manually clear the cache when using this technique.
if ($drop === TRUE) {
    $this->db->data_cache = array();
I realize I could capture the return query from the drop_table() method in order to test it instead of using table_exists(), but logically it would seem that either way should work correctly.

This still seems to be unresolved...

File an official Issue: https://github.com/EllisLab/CodeIgniter/issues
Or no one will see it.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.