Welcome Guest, Not a member yet? Register   Sign In
looping inside of a model
#3

[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.


Messages In This Thread
looping inside of a model - by El Forum - 01-29-2009, 01:00 AM
looping inside of a model - by El Forum - 01-29-2009, 01:30 AM
looping inside of a model - by El Forum - 01-29-2009, 06:42 AM
looping inside of a model - by El Forum - 01-29-2009, 12:19 PM
looping inside of a model - by El Forum - 01-29-2009, 01:26 PM
looping inside of a model - by El Forum - 01-29-2009, 01:36 PM
looping inside of a model - by El Forum - 01-29-2009, 02:43 PM
looping inside of a model - by El Forum - 05-01-2009, 10:57 PM
looping inside of a model - by El Forum - 05-02-2009, 11:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB