php-crud-api
php-crud-api copied to clipboard
Join returns list (instead of object) on 1-to-1 relationship
join returns a subobject array even if it has a 1 to 1 relationship
not really a problem.. just not to access the object using its index [0]
How would one differentiate a 1 to 1 relationship from a 1 to many relationship in SQL? Can you share your table create script for two tables with a 1 to 1 relationship?
well.. most of the times I try to find myself around..maybe I'm missing something.. but if u set the foreign key as unique key you get a 1 to 1 relationship.. am I wrong?
am I wrong?
No.. you aren't, it is a great suggestion. I guess I could try to detect the combination of a FK and a unique constraint. I'll turn this into an enhancement.
There may be a problem of a table having two 1-on-1 relationships with another table, but that is an edge case and may be solved with some form of aliasing.