#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,650
    Rep Power
    171

    A question about [CodeIgniter's] active records


    Hi
    I send data to model like this:
    PHP Code:
    $this->load->model('model_products');
    $data = array('selected_data'=>$selected_data'url'=>base_url(''), 'classes'=>$classes'statuses'=>$status,'categories'=>$categories,'selected_data'=>$selected_data,'header'=>'Search For Products','price_type'=>$this->price_type);
                
    $this->load->view('product_search_form'$data); 
    And in model I simply:
    PHP Code:
    public function results_products($data$record_start=0,$number_of_records=20)
            {
                
    $query $this->db->select('products_table.id, code, class, category, status, price, production_date, products_status.title AS STATUS')->from('products_table')->join('products_status''products_status.id = products_table.status')->get_where(''$data$number_of_records$record_start0);
                return 
    $query->result_array(); 
            } 
    How can I change the model and controller so I get price between X and Y in the system below?
    Thanks
    Last edited by requinix; May 11th, 2013 at 06:51 AM. Reason: edited title to make it clearer it's a php question
  2. #2
  3. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,650
    Rep Power
    171
    Seriously no one knows this?
  4. #3
  5. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,120
    Rep Power
    4274
    Originally Posted by zxcvbnm
    Seriously no one knows this?
    not likely in this forum

    moving thread to php forum

    Comments on this post

    • requinix agrees : which is where it was originally :rolleyes:
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,969
    Rep Power
    374
    in your controller, i dont see you passing anything to function in your model?

    also how are you going to pass in x & y values? user input etc? I would have thought it to be too hard (unless i am missing the big picture)

    //controller
    //get the two "intervals" from somewhere called min & max
    //$this->MODEL->function($min, $max)

    in the model:

    function function($min, max){
    $this->db->where('price >', $min);
    $this->db->or_where('price <', $max);

    }


    Originally Posted by zxcvbnm
    Hi
    I send data to model like this:
    PHP Code:
    $this->load->model('model_products');
    $data = array('selected_data'=>$selected_data'url'=>base_url(''), 'classes'=>$classes'statuses'=>$status,'categories'=>$categories,'selected_data'=>$selected_data,'header'=>'Search For Products','price_type'=>$this->price_type);
                
    $this->load->view('product_search_form'$data); 
    And in model I simply:
    PHP Code:
    public function results_products($data$record_start=0,$number_of_records=20)
            {
                
    $query $this->db->select('products_table.id, code, class, category, status, price, production_date, products_status.title AS STATUS')->from('products_table')->join('products_status''products_status.id = products_table.status')->get_where(''$data$number_of_records$record_start0);
                return 
    $query->result_array(); 
            } 
    How can I change the model and controller so I get price between X and Y in the system below?
    Thanks

IMN logo majestic logo threadwatch logo seochat tools logo