Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

belongsTo doesn't find right foreingKey #285

Open
lamalab opened this issue Dec 5, 2015 · 3 comments
Open

belongsTo doesn't find right foreingKey #285

lamalab opened this issue Dec 5, 2015 · 3 comments

Comments

@lamalab
Copy link

lamalab commented Dec 5, 2015

If foreingKey is not specified belongsTo doesn't find the right function to determine it.
in version 3.0.0 this was the code:

$backtrace = debug_backtrace(false);
$caller = ($backtrace[1]['function'] == 'handleRelationalArray')? $backtrace[3] : $backtrace[1];
$relation = $caller['function'];

in the latest release (3.2.0) is:

if ($backtrace[1]['function'] == 'handleRelationalArray') {
    $relation = $backtrace[1]['args'][0];
} else {
    $relation = $backtrace[3]['function'];
}

As you can see, in 3.2.0 relase $backtrace[1] and backtrace[3] are inverted compared to the version 3.0.0 and this release works well.
Inverting $backtrace[1] with $backtrace[3] works well.
Thanks ENx

@duongtdvn
Copy link

I do also getting problem on belongsTo if local_key is not specified. When calling associate function it trying to insert value to a column named call_id which doesn't available.

@ManiacTwister
Copy link

I can confirm this issue.

@pjona
Copy link

pjona commented Mar 9, 2017

There is pull request with it: #295

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants