0

I am a bit stuck.

I have the below controller function. this works 100% with no issues.

function new_blank_order_lines() 
{
          $data = array(
           'project' =>$this->input->post('project'),
           'millcoords' => $this->sales_model->get_mill_coords($this->input->post('mill')),
           'custcoords' => $this->sales_model->get_cust_coords($this->input->post('deliveryaddressid')),

          );
    $this->load->view('sales/new_blank_order_lines',$data);

What I want to do is pass more model information to the view. my problem however is that I am needing the results of the previous model queries for my new model query. so I want to add to the array as follows:

   $data = array(
       'project' =>$this->input->post('project'),
       'millcoords' => $this->sales_model->get_mill_coords($this->input->post('mill')),
       'custcoords' => $this->sales_model->get_cust_coords($this->input->post('deliveryaddressid')),
       'customersinrange' =>  $this->sales_model->get_customers_in_range($millcoords,$custcoords),            
      );

So I want to pass two values to the model function get_customers_in_range. I want to pass the results of millcoords and the results of custcoords.

How can I achieve this so that the controller can use the results of a model query to execute a new model query?

Thanks as always, Ryan

4

3 回答 3

4

尝试这个:

function new_blank_order_lines() 
{
    $data                       = array();
    $data['project']            = $this->input->post('project', true);
    $data['millcoords']         = $this->sales_model->get_mill_coords( $this->input->post('mill') );
    $data['custcoords']         = $this->sales_model->get_cust_coords($this->input->post('deliveryaddressid'));
    $data['customersinrange']   = $this->sales_model->get_customers_in_range($data['millcoords'], $data['custcoords']);
    $this->load->view('sales/new_blank_order_lines',$data);
于 2013-10-10T08:55:34.067 回答
2
$millcoords = $this->sales_model->get_mill_coords($this->input->post('mill');
$custcoords = $this->sales_model->get_cust_coords($this->input->post('deliveryaddressid');
$customersinrange = $this->sales_model->get_customers_in_range($millcoords,$custcoords);
    $data = array(
           'project' =>$this->input->post('project'),
           'millcoords' => $millcoords,
           'custcoords' => $custcoords,
           'customersinrange' => $customersinrange,            
          );


    $this->load->view('sales/new_blank_order_lines',$data);
于 2013-10-10T08:52:31.990 回答
2

试试这个:

    $millcoords = $this->sales_model->get_mill_coords($this->input->post('mill'));
$custcoords = $this->sales_model->get_cust_coords($this->input->post('deliveryaddressid'));
    $data = array(
           'project' =>$this->input->post('project'),
           'millcoords' => $millcoords,
           'custcoords' => $custcoords,
           'customersinrange' =>  $this->sales_model->get_customers_in_range($millcoords,$custcoords),            
          );
于 2013-10-10T08:52:51.727 回答