Skip to content

3.0 - ORM Upgrade guide #1228

@davidyell

Description

@davidyell

Document: http://book.cakephp.org/3.0/en/appendices/orm-migration.html#inflection-rules-updated

Section:

Note
BelongsTo and HasOne associations will use the singular form, while HasMany and BelongsToMany (HABTM) will use plural forms.

This does not seem to be true.

I have setup Questions and Users

// QuestionsTable.php
$this->belongsTo('User');

// UsersTable.php
$this->hasMany('Questions');

$questions = $this->Questions->find()
    ->contain('User')
    ->order(['Questions.created' => 'DESC']);
// Errors with 'Questions is not associated with Users'

I've had to update my relationship to be $this->belongsTo('Users'); and my contain to ->contain('Users')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions