Welcome Guest, Not a member yet? Register   Sign In
About:pagination; Q: Does the config data should reside in a model or in controller?
#6

[eluser]developer10[/eluser]
[quote author="markup2go" date="1260304649"]I'm not quite sure what you're asking but you can pass variables the usual way.

Code:
$config['total_rows'] = $this->your_model->custom_count_function($someVariable);
[/quote]

here's my model:

Code:
function fetch_all($getDjelatnost, $getGrad, $getSlovo, $getStart, $per_page, $getFid, $getPortfolio)
    {    
        $upit = "    SELECT * FROM _tbl_firme LEFT JOIN tbl_djelatnosti ON _tbl_firme.d_id = tbl_djelatnosti.d_id
                    WHERE ";
            if($getDjelatnost && $getDjelatnost != 'Sve')
                $out = " d_seo = '$getDjelatnost' AND ";
            else $out = "";
                $upit .= $out;
                
            if($getGrad && $getGrad != 'Svi')
                $out = " _f_grad = '$getGrad' AND ";
            else $out = "";
                $upit .= $out;
                
            if($getSlovo)
                $out = " _f_ime LIKE '$getSlovo%' AND ";
            else $out = "";
                $upit .= $out;
                
            if($getFid)
                $out = " f_id = '$getFid' AND ";
            else $out = "";
                $upit .= $out;
                
            if($getPortfolio)
                $out = " _F_KEYWORD = '$getPortfolio' AND ";
            else $out = "";
                $upit .= $out;
                        
        $upit .= " f_vidljivo = 1 ORDER BY f_istaknuto DESC, _f_ime ASC ";
                
            $limited = $upit . " LIMIT ";        
                if($getStart)
                    $out = $getStart;
                else $out = 0;
                    $limited .= $out;
            $limited .= ", " . $per_page;

        $query = $this->db->query($limited);
        
        $numFiltered = $this->db->query($upit);
                
        if($query->num_rows() > 0) {
            $result = $query->result();
        }
        
        return $result;
    }

now i moved my $config['data'] to the controller:

Code:
$config['total_rows'] = $this->Adresar_model->custom();  // (old code) $numFiltered->num_rows();

in my model, below the fetch_all() function, will come custom() function.
is it possible to have the variable $numFiltered from fetch_all() in it, or i have to run the same query in custom() as well, in
order to count the rows, get results, and have its value called from the controller the way you suggested:

Code:
$config['total_rows'] = $this->Adresar_model->custom();


Messages In This Thread
About:pagination; Q: Does the config data should reside in a model or in controller? - by El Forum - 12-08-2009, 09:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB