Welcome Guest, Not a member yet? Register   Sign In
Just a little explanation for a beginner...
#12

[eluser]knucklehead[/eluser]
[quote author="Colin Williams" date="1254973465"]1. If you don't see a need for them, don't include them.[/quote]
Understood! =)

[quote author="Colin Williams" date="1254973465"]2. You want to do a JOIN query in the model, then, still in the model, iterate over the result and group multiple entries by the primary object's primary key field. This is nearly always the process for many-to-many relationships[/quote]
OK, I understand that part and I am doing it in both my models, but let me try to explain what I meant;

I have an artist_model in which i get some array of artist(s) which was created with huge mysql query. With my 'formatting function' I make my artist 'object' with polished properties (some of them are strings, some arrays, etc). This is the thing you were saying about, right? Something like this:
Code:
private function format_artist($r){
    
    $a = array();
    foreach ($r as $artist){
        $a[$artist->artistID]['artistID'] = $artist->artistID;
        $a[$artist->artistID]['artistName'] = $artist->artistName;
        $a[$artist->artistID]['links'][$artist->artistLinkURL] = $artist->artistLinkURL;
        $a[$artist->artistID]['descriptions'][$artist->artistDescription] = $artist->artistDescription;
        $a[$artist->artistID]['categories'][$artist->artistCat] = $artist->artistCat;
    }
    return $a;
    
}

In my events_model I need to use another huge mysql query and I would like to avoid extending it with artist's huge query to retrieve everything I need. Instead of that, I imagine I could 'attach' those already formatted artist 'objects' to each event they belong to. After that, my final event array would have a property like 'event_artists' which would be some array of objects (already formatted artists). I'm not sure if is it smart to do it that way... I mean, is it hard to manipulate with such data later?

Thanks for help =)


Messages In This Thread
Just a little explanation for a beginner... - by El Forum - 09-25-2009, 06:52 AM
Just a little explanation for a beginner... - by El Forum - 09-25-2009, 06:59 AM
Just a little explanation for a beginner... - by El Forum - 09-25-2009, 07:21 AM
Just a little explanation for a beginner... - by El Forum - 09-25-2009, 07:46 AM
Just a little explanation for a beginner... - by El Forum - 09-25-2009, 09:07 AM
Just a little explanation for a beginner... - by El Forum - 09-25-2009, 09:27 AM
Just a little explanation for a beginner... - by El Forum - 09-25-2009, 10:27 AM
Just a little explanation for a beginner... - by El Forum - 09-25-2009, 11:04 AM
Just a little explanation for a beginner... - by El Forum - 09-26-2009, 12:20 AM
Just a little explanation for a beginner... - by El Forum - 10-07-2009, 04:08 PM
Just a little explanation for a beginner... - by El Forum - 10-07-2009, 04:44 PM
Just a little explanation for a beginner... - by El Forum - 10-07-2009, 05:07 PM
Just a little explanation for a beginner... - by El Forum - 10-07-2009, 05:14 PM
Just a little explanation for a beginner... - by El Forum - 10-07-2009, 05:24 PM
Just a little explanation for a beginner... - by El Forum - 10-08-2009, 05:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB