diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-08-02 18:55:17 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-08-02 18:55:17 +0000 |
commit | 9ad0a7ea9b9fefecef1d33ee26d654201f9627d1 (patch) | |
tree | be393990e3c2179b9aacf7a436ee6a1d201f3804 /includes/database/mysql | |
parent | 36da783d5310d680d137ccaeb116691e35be424a (diff) | |
download | brdo-9ad0a7ea9b9fefecef1d33ee26d654201f9627d1.tar.gz brdo-9ad0a7ea9b9fefecef1d33ee26d654201f9627d1.tar.bz2 |
#851168 by Stevel, Damien Tournoud: Fixed db_find_tables() expects tables to be prefixed, inconsistent implementation and documentation.
Diffstat (limited to 'includes/database/mysql')
-rw-r--r-- | includes/database/mysql/schema.inc | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/includes/database/mysql/schema.inc b/includes/database/mysql/schema.inc index ca7a14be4..1712ca2a4 100644 --- a/includes/database/mysql/schema.inc +++ b/includes/database/mysql/schema.inc @@ -30,16 +30,19 @@ class DatabaseSchema_mysql extends DatabaseSchema { * @return * A keyed array with information about the database, table name and prefix. */ - protected function getPrefixInfo($table = 'default') { + protected function getPrefixInfo($table = 'default', $add_prefix = TRUE) { $info = array('prefix' => $this->connection->tablePrefix($table)); - if (($pos = strpos($info['prefix'], '.')) !== FALSE) { - $info['database'] = substr($info['prefix'], 0, $pos); - $info['table'] = substr($info['prefix'], ++$pos) . $table; + if ($add_prefix) { + $table = $info['prefix'] . $table; + } + if (($pos = strpos($table, '.')) !== FALSE) { + $info['database'] = substr($table, 0, $pos); + $info['table'] = substr($table, ++$pos); } else { $db_info = Database::getConnectionInfo(); $info['database'] = $db_info['default']['database']; - $info['table'] = $info['prefix'] . $table; + $info['table'] = $table; } return $info; } @@ -52,10 +55,10 @@ class DatabaseSchema_mysql extends DatabaseSchema { * database as the schema unless specified otherwise, and exclude table_catalog * from the condition criteria. */ - protected function buildTableNameCondition($table_name, $operator = '=') { + protected function buildTableNameCondition($table_name, $operator = '=', $add_prefix = TRUE) { $info = $this->connection->getConnectionOptions(); - $table_info = $this->getPrefixInfo($table_name); + $table_info = $this->getPrefixInfo($table_name, $add_prefix); $condition = new DatabaseCondition('AND'); $condition->condition('table_schema', $table_info['database']); |