Permalink
Browse files

Consolidate table prefix removal.

  • Loading branch information...
1 parent c5d7637 commit 169b0a5c3f211e8ff8138514466b062acc7ff35e @predominant predominant committed May 31, 2011
Showing with 7 additions and 3 deletions.
  1. +7 −3 cake/libs/model/cake_schema.php
@@ -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);
@@ -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);
@@ -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
@@ -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.