Welcome Guest, Not a member yet? Register   Sign In
Work with result in controller
#1

[eluser]MaxEisley[/eluser]
Hello guys,

i really still cannot find how to work with results in Controller. I can work with results only in viewer.

This is my data model, this function check, if the customer with these parameters exists:
Code:
function checkcustomer($phone, $email, $name, $surname) {
      $q = $this->db->query('SELECT *
      FROM zakaznik
      WHERE Telefon = "'.$phone.'"
      AND Email = "'.$email.'"
      AND Jmeno = "'.$name.'"
      AND Prijmeni = "'.$surname.'"');
      
      return ($q->row());
    }

This is my controller getting valid entries from viewer. I want to check, if customer with these values exists and when yes, then get customer_ID, when doesn't exist, then create customer:
Code:
$data['customer'] = $this->data_model->checkcustomer($this->input->post('Phone'), $this->input->post('Email'), $this->input->post('FirstN'), $this->input->post('SecondN'));

if($customer->zakaznikID == '') {
              $id_customer = $this->data_model->createcustomer($this->input->post('Phone'), $this->input->post('Email'), $this->input->post('FirstN'), $this->input->post('SecondN'), $id_address);
        }
        
        else {
          $id_customer = $customer->zakaznikID;
        }

And it writes these errors, i dont know how to work with results from Model in Controller:
Message: Undefined variable: customer
Message: Trying to get property of non-object


Messages In This Thread
Work with result in controller - by El Forum - 04-28-2011, 02:34 PM
Work with result in controller - by El Forum - 04-28-2011, 03:16 PM
Work with result in controller - by El Forum - 04-28-2011, 03:24 PM
Work with result in controller - by El Forum - 04-28-2011, 04:27 PM
Work with result in controller - by El Forum - 04-29-2011, 01:32 AM
Work with result in controller - by El Forum - 04-29-2011, 01:49 AM
Work with result in controller - by El Forum - 04-29-2011, 06:49 AM
Work with result in controller - by El Forum - 04-29-2011, 12:34 PM
Work with result in controller - by El Forum - 04-30-2011, 04:51 PM
Work with result in controller - by El Forum - 05-03-2011, 05:15 PM
Work with result in controller - by El Forum - 05-04-2011, 09:32 AM



Theme © iAndrew 2016 - Forum software by © MyBB