mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Only count _id
if it is the last 3 characters in the field name.
This prevents issues when baking models for tables containing `_id`. Fixes #3230
This commit is contained in:
parent
c92769c980
commit
b8e21c99ee
1 changed files with 1 additions and 1 deletions
|
@ -572,7 +572,7 @@ class ModelTask extends BakeTask {
|
|||
public function findBelongsTo(Model $model, $associations) {
|
||||
$fieldNames = array_keys($model->schema(true));
|
||||
foreach ($fieldNames as $fieldName) {
|
||||
$offset = strpos($fieldName, '_id');
|
||||
$offset = substr($fieldName, -3) === '_id';
|
||||
if ($fieldName != $model->primaryKey && $fieldName !== 'parent_id' && $offset !== false) {
|
||||
$tmpModelName = $this->_modelNameFromKey($fieldName);
|
||||
$associations['belongsTo'][] = array(
|
||||
|
|
Loading…
Add table
Reference in a new issue