[eluser]umefarooq[/eluser]
its better to loop in controller just pass the parameters to your model, either tables name, fields to be selected from table like this
Code:
if(what ever true){
$fields = array(feild1,field2,...,n);
$getvalue = $this->modelname->yourfunction(tablename,$fields);
}
else{
foreach(what you want to loop){
$getvalue = $this->modelname->yourfunction(tablename,$fields);
}
foreach(what you want to loop){
$getvalue1 = $this->modelname->yourfunction(tablename,$fields);
}
}
use these parameters from controller and use in you model and your model can be some thing like this
Code:
function yourfunction($tables='', $fields=''){
do what ever with your database. no need to loop here
return your values.
}
or you can create other function with different parameters in your model for your looping code.