$ this-> db-> insert_id()在mysql codeigniter中不起作用 [英] $this->db->insert_id() not working in mysql codeigniter

查看:59
本文介绍了$ this-> db-> insert_id()在mysql codeigniter中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想从codeiginitor的mysql表中获取最新的自动生成的密钥.但这是行不通的.我已经尝试过此代码
$this->db->insert_id()
以及
$this->db->mysql_insert_id()
我收到以下错误
Severity: Notice
Message: Undefined property: CI_DB_mysql_driver::$insert_id

MySQL不支持insert_id函数?我们如何使其工作?

I am just trying to get the latest auto generated key from the mysql table from codeiginitor. But it is not working some how. I have tried this code
$this->db->insert_id()
as well as
$this->db->mysql_insert_id()
I am getting the following error
Severity: Notice
Message: Undefined property: CI_DB_mysql_driver::$insert_id

is the insert_id function not supported for mysql? How can we make it work?

推荐答案

这是我尝试插入数据并获取插入ID的代码,

This is the code I tried to insert the data and get the insert id,

$this->db->insert('table_name',$data); $id = $this->db->mysql_insert_id();

$this->db->insert('table_name',$data); $id = $this->db->mysql_insert_id();

它对我不起作用.我已经将DB Driver用作"mysql".然后,我安装了"mysqli",并在database.php中更改了数据库驱动程序名称,例如
$db['default']['dbdriver'] = 'mysqli';
现在对我来说很好.

It is not working for me. I have used DB Driver as "mysql". Then I have installed "mysqli" and changed the DB driver name in database.php like,
$db['default']['dbdriver'] = 'mysqli';
Now it is working fine for me.

这篇关于$ this-> db-> insert_id()在mysql codeigniter中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆