我有控制器和型号。我正在修改模型中的变量值,但它没有反映在控制器中,我在OOP中并不是那么多专家。
// controller class structure
class Leads_import extends CI_Controller {
public $total = 0;
public function import(){
$this->xml_model->imsert();
echo $this->total;
}
}
// model class structure
class xml_model extends CI_Model {
public function insert(){
this->total = 10;
}
}
答案 0 :(得分:0)
试试这个:
// controller class structure
class Leads_import extends CI_Controller {
public $total = 0;
public function import(){
$this->total = $this->xml_model->imsert();
}
}
型号:
// model class structure
class xml_model extends CI_Model {
public function insert(){
return 10;
}
}
答案 1 :(得分:0)
您必须查看$total
的{{1}}或更新xml_model
的{{1}}。您正在读取控制器中的错误变量,它永远不会更新。
这是我建议的,不知道你真正想要做什么:
$total