Skip to content

Commit

Permalink
Consolidate table prefix removal.
Browse files Browse the repository at this point in the history
  • Loading branch information
predominant committed May 31, 2011
1 parent c5d7637 commit 169b0a5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cake/libs/model/cake_schema.php
Expand Up @@ -257,7 +257,7 @@ function read($options = array()) {
if ($prefix && strpos($table, $prefix) !== 0) {
continue;
}
$table = preg_replace('/^' . preg_quote($prefix) . '/', '', $table);
$table = $this->_noPrefixTable($prefix, $table);

if (in_array($fulltable, $currentTables)) {
$key = array_search($fulltable, $currentTables);
Expand All @@ -279,7 +279,7 @@ function read($options = array()) {
}
if (in_array($withTable, $currentTables)) {
$key = array_search($withTable, $currentTables);
$noPrefixWith = str_replace($prefix, '', $withTable);
$noPrefixWith = $this->_noPrefixTable($prefix, $withTable);

$tables[$noPrefixWith] = $this->__columns($Object->$class);
$tables[$noPrefixWith]['indexes'] = $db->index($Object->$class);
Expand All @@ -300,7 +300,7 @@ function read($options = array()) {
if (strpos($table, $prefix) !== 0) {
continue;
}
$table = preg_replace('/^' . preg_quote($prefix) . '/', '', $table);
$table = $this->_noPrefixTable($prefix, $table);
}
$Object = new AppModel(array(
'name' => Inflector::classify($table), 'table' => $table, 'ds' => $connection
Expand Down Expand Up @@ -695,4 +695,8 @@ function _compareIndexes($new, $old) {
}
return array_filter(compact('add', 'drop'));
}

function _noPrefixTable($prefix, $table) {
return preg_replace('/^' . preg_quote($prefix) . '/', '', $table);
}
}

0 comments on commit 169b0a5

Please sign in to comment.