2017-10-17 40 views
1

如何從模型中獲取值以及如何在控制器中使用?我正嘗試從發送電子郵件的數據庫中獲取電子郵件ID。我沒有收到電子郵件提交的價值。如何從模型中獲取值以及如何在控制器中使用

這裏是我的代碼如下

控制器代碼

function NAME(){ 

    $resultt = $this->Products_model->delete_mail($id); 
    $data['productemail'] = $resultt->email; 

    $config['protocol'] = 'smtp'; 

    $config['smtp_host'] = 'mail.himagri.com'; 

    $config['smtp_port'] = '587'; 

    $config['smtp_timeout'] = '7'; 

    $config['smtp_user'] = '[email protected]'; 

    $config['smtp_pass'] = '[email protected]'; 

    $config['charset'] = 'utf-8'; 

    $config['newline'] = "\r\n"; 

    $config['mailtype'] = 'html'; // or html 

    $config['validation'] = TRUE; // bool whether to validate email or not  

    $this->email->initialize($config); 
    $this->email->from('[email protected]', 'Himagri'); 
    $this->email->to('[email protected]');//i want to use email id 

    $this->email->subject('test delete mail'); 

    $body = $this->load->view('deletemailer', $data, TRUE); 

    $this->email->message($body); 


    $this->email->send(); 

    echo $this->email->print_debugger(); 

    $this->product_display($data); 
} 

型號代碼

public function delete_mail($id) { 
     $this->db->select('*'); 
     $this->db->from('supplier_registration'); 
     $this->db->join('approve_products', 'supplier_registration.id=approve_products.supplier_id_fk'); 
     $this->db->where('approve_products.id', $id); 
     $query = $this->db->get(); 
     return $query->result(); 
    } 

回答

1

$query->row();因爲你取一排只有

public function delete_mail($id) { 

     $this->db->select('*'); 
     $this->db->from('supplier_registration'); 
     $this->db->join('approve_products', 'supplier_registration.id=approve_products.supplier_id_fk'); 
     $this->db->where('approve_products.id', $id); 
     $query = $this->db->get(); 
     return $query->row(); 
    } 
上作爲託運
1

回報從模型結果如下:

return $query->row(); 

並在控制器中調用該函數並獲取數據。

$resultt = $this->Products_model->delete_mail($id); 
$data['productemail'] = $resultt->email; 
相關問題