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

[eluser]jedd[/eluser]
And yes, if you want to restructure your data - such that you have a 2D array where the first dimension is the artist_id say, as shown, then I'd probably do that in my model - especially if that was what I consistently wanted back from that function.

If I wanted different formatted results, then .. it's a bit less obvious which way to go. You could have a helper function that mungs consistently formatted input into whatever output layout you want, or duplicate your model methods to provide the different outputs, or a private function within your controller (especially if the scope of this problem is a single controller).

Not to rain on BrianDHall's appreciation of objects, but in response to your 'array of array's question/example above, here's what I do for one of my model methods - it might be of relevance:

Code:
function  get_appellations_info () {
        $query_string = "SELECT
                            *
                        FROM
                            appellation";
        $return_array = array();
        $rows = $this->my_get_rows($query_string);      // my_get_rows just wraps some stuff around a basic result_array() call
        if ($rows)  {
            foreach ($rows as $row)
                $return_array[$row['id']] = $row['text'];
            return $return_array;
            }
       else
             return FALSE;
        }

In this particular instance I wanted the key to be the ID and preferred to mung it in the model. I could probably have adjusted my view logic to cope with an array of two-element arrays (id and text). Six of one, in many cases, I suspect.


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