diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index 4a00631ebb1..1627d6a624c 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -623,9 +623,9 @@ public function findHasAndBelongsToMany(Model $model, $associations) { $offset = strpos($otherTable, $model->table . '_'); $otherOffset = strpos($otherTable, '_' . $model->table); - if ($offset === 0) { + if ($offset !== false) { $tableName = substr($otherTable, strlen($model->table . '_')); - } elseif ($otherOffset === 0) { + } elseif ($otherOffset !== false) { $tableName = substr($otherTable, 0, $otherOffset); } if ($tableName && in_array($tableName, $this->_tables)) {