Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
many to many, and its related rows
  • If we are getting a list (list, list_music, list_videos related by $_one_to_many) of entries by genre (genre, genre_list, list related by $_many_many) by 'rock' and we are getting all the lists with 'rock' we would do something like this:
    Model_Genre::find($tag, array('related' => array('list','music','videos')));
    
        protected static $_many_many = array(
                'music' => array(
                    'key_from'          => 'tag_id',
                    'key_through_from'  => 'tag_id',
                    'key_through_to'    => 'list_id',
                    'key_to'            => 'list_id',
                    'table_through'     => 'lists_tags',
                    'model_to'          => 'Model_Music',
                    'cascade_save'      => true,
                    'cascade_delete'    => false,
                ),
    
                'video' => array(
                    'key_from'          => 'tag_id',
                    'key_through_from'  => 'tag_id',
                    'key_through_to'    => 'list_id',
                    'key_to'            => 'list_id',
                    'table_through'     => 'lists_tags',
                    'model_to'          => 'Model_Video',
                    'cascade_save'      => true,
                    'cascade_delete'    => false,
                ),
    
                'list' => array(
                    'key_from'          => 'tag_id',
                    'key_through_from'  => 'tag_id',
                    'key_through_to'    => 'list_id',
                    'key_to'            => 'list_id',
                    'table_through'     => 'lists_tags',
                    'model_to'          => 'Model_List',
                    'cascade_save'      => true,
                    'cascade_delete'    => false,
                ),
        );
    

    is there any other way of handling this ? in a way where we can get 'music' or 'video' with its related list rows?
    Model_Genre::find($tag, array('related' => array('music')));
    

    Where it gets 'music' array and its related 'list' array ?
  • Jelmer Schreuder wrote on Saturday 23rd of April 2011:
    Not yet, this will be in 1.1: https://github.com/fuel/orm/issues/6

    Thanks for the info.
  • @stewart When you start out with "may I hijack this thread" you should realize you're doing something wrong. Don't hijack thread, start your own.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion