我有需要使用 enterie id 的功能。按 id 选择 enterie,显示它并更新 DB 中的行。不会复制所有代码,只是主要思想
控制器
function edit_advert()
{
$id = $this->uri->segment(3); //Here i get my enterie id
$this->load->model('model_adverts');
$myadvert = $this->model_adverts->get_enterie($id); //passing id to model function
//where i find enterie, select it from DB and pass it back to controller
//and then do if() stuff, where i give error message or pass returned enterie to
//view and display it .
}
function update_enterie() //in view i got form with values from DB, after editing
//fields, form submits to this function
{
do form validation stuff etc
And here i need to get $id again and pass it to model, so i can do query update
where $id = id
}
那么,我如何才能再次访问该 $id 变量?