我想在Db中获取最后插入记录的id.但我得到了错误
Parse error: syntax error, unexpected T_RETURN in Z:\www\CI4\application\models \report_model.php on line 69
Run Code Online (Sandbox Code Playgroud)
我的模特:
function getLastInserted() {
$query ="SELECT $id as maxID from info where $id = LAST_INSERT_ID()"
return $query; //line 69
}
Run Code Online (Sandbox Code Playgroud)
我的控制器:
function index()
{
$id=$this->report_model->getLastInserted();
$this->load->view('u_type1',$id);
}
Run Code Online (Sandbox Code Playgroud)
bir*_*ric 26
假设您正在使用CI数据库库,则可以使用$this->db->insert_id().
function getLastInserted() {
return $this->db->insert_id();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
39851 次 |
| 最近记录: |