VoodOrm
VoodOrm copied to clipboard
Relationships are broken
VoodOrm.php on line 1252 there is a problem with:
$prop = array_merge($_def, $args);
It doesn't merge arrays correctly. In __call(), $args is considered to be an array already, and if I pass an array:
[
'relationship' => Voodoo\VoodOrm::HAS_ONE,
'localKey' => 'user_id',
'foreignKey' => 'id'
]
to it, then $args is something like this:
[
'0' => [
'relationship' => Voodoo\VoodOrm::HAS_ONE,
'localKey' => 'user_id',
'foreignKey' => 'id'
]
];
And so, the array merge gives me something like this:
[
'relationship' => self::HAS_MANY
'localKey' => '',
'foreignKey' => ''
'0' => [
'relationship' => Voodoo\VoodOrm::HAS_ONE,
'localKey' => 'user_id',
'foreignKey' => 'id'
]
];
If i try this example:
$friend->user(Voodoo\VoodOrm::HAS_ONE, "friend_id");
I get an error:
"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user_id' in 'where clause'"
Also, the documentation doesn't add up to the code. I found this mainly in Relationships, as I have not yet tried other stuff. Maybe the relationships are not broken, but the examples from documentation I tryed are incorrect. For instance, this constant doesn't exist in the code:
Voodoo\VoodOrm::REL_LAZYONE