You are here

function simpletest_get_like_tables in SimpleTest 6

Find all tables that are like the specified base table name.

Parameters

string $base_table Base table name.:

boolean $count Return the table count instead of list of tables.:

Return value

mixed Array of matching tables or count of tables.

1 call to simpletest_get_like_tables()
simpletest_clean_database in ./simpletest.module
Removed prefixed talbes from the database that are left over from crashed tests.

File

./simpletest.module, line 250

Code

function simpletest_get_like_tables($base_table = 'simpletest', $count = FALSE) {
  global $db_url, $db_prefix;
  $url = parse_url($db_url);
  $database = substr($url['path'], 1);
  $select = $count ? 'COUNT(table_name)' : 'table_name';
  $result = db_query("SELECT {$select} FROM information_schema.tables WHERE table_schema = '{$database}' AND table_name LIKE '{$db_prefix}{$base_table}%'");
  if ($count) {
    return db_result($result);
  }
  $tables = array();
  while ($table = db_result($result)) {
    $tables[] = $table;
  }
  return $tables;
}