Welcome Guest, Not a member yet? Register   Sign In
DataMapper: Find with No Related Objects
#3

[eluser]jonahdahlquist[/eluser]
Not quite, I don't want to check if it's not related to a specific object, I wanted get ones that aren't related to any objects at all. I did resolve it by doing this:

Code:
$c = new Category();

$top_level_categories = $c
    ->where_related_parents('id IS NULL')
    ->get();

If it's an integer auto-increment column, no values will actually be NULL, but if there are no related rows in the join, it will come out as NULL.


Messages In This Thread
DataMapper: Find with No Related Objects - by El Forum - 11-19-2012, 04:56 PM
DataMapper: Find with No Related Objects - by El Forum - 11-19-2012, 05:30 PM
DataMapper: Find with No Related Objects - by El Forum - 11-21-2012, 10:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB