php - Kohana ORM - has many through models stored in parent model -
i had many problems has_many-through relationships found nice example here solved of problems. however, according code presented below have couple questions.
firstly, code:
$artists = orm::factory('artist')->find_all(); foreach ( $artists $artist ) { foreach ( $artist->media->find_all() $m ) { echo $m->name; } } 1) example controller. if want store media in $artists send 1 variable view? possible store media media property in artist object? (i mean example $artists[0]->media[0]->name)
2) possible load $artists without loop?
1) if understood correctly, need element medias
$artists = orm::factory('artist')->find_all()->as_array(); $media = $artists[0]->media->find_all()->as_array(); // media of first artist $name = $media[0]->name; 2) see above $artists array of orm objects
Comments
Post a Comment