How can i pass a parameter (that is a returned value of another model function) to a function of a model class.
here’s my model class functions
public function get_products_categories()
{
$query = $this->db->query('SELECT DISTINCT category
FROM products');
return $query->result_array();
}
public function get_products_names($category)
{
$query = $this->db->query('SELECT name
FROM products
WHERE category=$category');
return $query->result_array();
}
and here’s how I am doing in the controller class
$this->load->model('products_model');
$data['products_categories'] = $this->products_model->get_products_categories();
$data['products_names'] = $this->products_model->get_products_names();
Now what I want is to pass $products_categories to the function $this->products_model->get_products_names(); but this is not possible $products_categories is not variable here in the controller class but in the view file, it can be used as a variable
Any Ideas ?
What do you want to do? For example, if you want to list all of your products in the categories, you can do this: