// Location model protected static $_many_many = array( 'categories' => array( 'key_from' => 'id', 'key_through_from' => 'location_id', 'table_through' => 'categories_locations', 'key_through_to' => 'category_id', 'model_to' => 'Model_Category', 'key_to' => 'id', 'cascade_save' => true, 'cascade_delete' => true, ) ); // Category model protected static $_many_many = array( 'locations' => array( 'key_from' => 'id', 'key_through_from' => 'category_id', 'table_through' => 'categories_locations', 'key_through_to' => 'location_id', 'model_to' => 'Model_Location', 'key_to' => 'id', 'cascade_save' => true, 'cascade_delete' => true, ), );
// actual values in categories_locations category_id location_id 27 44 55 44 56 44 58 44 25 5 27 5 26 5 $location = Model_Location::find(44); echo count($location->categories); // will echo 1?!? WTF? $location2 = Model_Location::find(5); echo count($location2->categories); // will echo 3!!!
It looks like you're new here. If you want to get involved, click one of these buttons!