在同一时刻将 id(自动递增)插入其他 table
Insert id (auto increment) into other table in same moment
我有 2 个 table:
客户端table:
--------------------------------------
id_client | name_client | email_client
--------------------------------------
技能table:
--------------------------------------
id_skill | client | number
--------------------------------------
我使用 CodeIgniter,我有一个添加新客户端的控制器。我有一个包含输入表单的表单,但在 client table
中,id_client
是 auto increment
,我想将 id_client
值插入 client
列中 [=18] =] 同时(控制器)。所以我有两个模型 $this->m_admin->save_client($clientdata);
和 $this->m_admin->save_skill($skilldata);
你能帮我吗,如何在同一时刻将自动递增ID插入到其他table中?
已解决,我使用 $this->db->insert_id()
自动递增获取最后一个 ID。首先 运行 主要查询,然后是第二个查询(需要第一个查询 ID 的查询)。有关 Codeigniter 用户指南中的更多信息 https://ellislab.com/codeigniter/user-guide/database/helpers.html
$this->db->insert_id()
现在我看到你找到了:)
我有 2 个 table:
客户端table:
--------------------------------------
id_client | name_client | email_client
--------------------------------------
技能table:
--------------------------------------
id_skill | client | number
--------------------------------------
我使用 CodeIgniter,我有一个添加新客户端的控制器。我有一个包含输入表单的表单,但在 client table
中,id_client
是 auto increment
,我想将 id_client
值插入 client
列中 [=18] =] 同时(控制器)。所以我有两个模型 $this->m_admin->save_client($clientdata);
和 $this->m_admin->save_skill($skilldata);
你能帮我吗,如何在同一时刻将自动递增ID插入到其他table中?
已解决,我使用 $this->db->insert_id()
自动递增获取最后一个 ID。首先 运行 主要查询,然后是第二个查询(需要第一个查询 ID 的查询)。有关 Codeigniter 用户指南中的更多信息 https://ellislab.com/codeigniter/user-guide/database/helpers.html
$this->db->insert_id()
现在我看到你找到了:)