php - Passing Array from Controller to Model CodeIgniter -


i ran trouble while passing array controller model in code igniter further processing.

controller:

public function list_out(){      $this->show_pagination();      $action = array(         'page'=>'public/'.$this->class_name.'/list',         'title'=>'my title',         'success'=>$this->success,         'data'=>$this->public_model->my_function(array('make'=>'apple','color'=>'black'))     );      $this->public_page($action); } 

model:

public function my_function($arr){            $this->db->select('main_tbl.*,image_table.image_url');     $this->db->from('main_tbl');             $this->db->join('image_tbl','image_tbl.prod_id=main_tbl.prod_id');     $this->db->where('main_tbl.prod_status',1);     $table = 'main_tbl';      ($i = 0; $i <  count($arr); $i++) {         $key=key($arr);         $val=$arr[$key];         if ($val<> ' ') {             $this->db->where($table.'.'.$key,$val);         }         next($arr);     }         $this->db->where('image_tbl.image_cover',1);     $this->db->order_by('prod_id','desc');     $query = $this->db->get();       return $query->result();  } 

error :

message: key() expects parameter 1 array, string given message: next() expects parameter 1 array, string given

when same array placed inside my_function() in model, works well.

ex:

public my_function(){    $arr = array(       'make'=>'apple',       'color'=>'black'   );    $this->db->select('main_tbl.*,image_table.image_url');   ........   } 

what issue here? highly appreciated.

thanks in advance.

please pass array that

public function list_out(){      $this->show_pagination();     $arr['make'] = 'apple';     $arr['color'] = 'black';     $action = array(         'page'=>'public/'.$this->class_name.'/list',         'title'=>'my title',         'success'=>$this->success,         'data'=>$this->public_model->my_function($arr)     );      $this->public_page($action); } 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -