Welcome Guest, Not a member yet? Register   Sign In
for loops in model that return an array
#2

[eluser]theprodigy[/eluser]
Quote:I figure the above code goes in the model and called by the controller.
I am stumped. I am new to codeigniter and mvc. I’m thinking there is an easy solution, but its hard hitting for me. thanks in advance.

You are right in the fact that this code should belong in the model.
All you would need to do is create a function, put this code in the function, have the function return the $pball array to the controller.

Your model function might look something like:
Code:
function get_pball_counts()
{
    for(  $i =1; $i <= 39 ; $i++ )
    {
        $this->db->select('count(*)',false);
        $this->db->where('pball', $i);
        $result = $this->db->get('pball');

        $pball[$i] = $result->num_rows();
    }

    return $pball;
}


Messages In This Thread
for loops in model that return an array - by El Forum - 02-08-2010, 04:46 PM
for loops in model that return an array - by El Forum - 02-08-2010, 05:49 PM
for loops in model that return an array - by El Forum - 02-08-2010, 07:17 PM
for loops in model that return an array - by El Forum - 02-08-2010, 07:24 PM
for loops in model that return an array - by El Forum - 02-08-2010, 07:26 PM
for loops in model that return an array - by El Forum - 02-08-2010, 07:34 PM



Theme © iAndrew 2016 - Forum software by © MyBB