【问题标题】:How to insert data into multiple tables using codeIgniter如何使用codeIgniter将数据插入多个表
【发布时间】:2015-08-21 04:52:09
【问题描述】:

我正在开发 MVC 框架(codeIgniter)

tbl_emp, tbl_address, tbl_salary

我在一个数据库中创建了 3 个表,现在我想通过使用 INSERT 的单个查询将数据传递到 3 个表中。请帮我解决这个问题...

【问题讨论】:

  • 您想使用单个 SQL(问题标记?)语句将数据放入 3 个表中?您是否已经阅读了一些 SQL 教程/学习资料?

标签: codeigniter phpmyadmin


【解决方案1】:

你不能在一个语句中做到这一点,但你可以在事务中做到:

$this->db->trans_start();
$this->db->query('INSERT QUERY...');
$this->db->query('ANOTHER INSERT QUERY...');
$this->db->query('AND YET ANOTHER INSERT QUERY...');
$this->db->trans_complete();

【讨论】:

    猜你喜欢
    • 2014-09-07
    • 1970-01-01
    • 1970-01-01
    • 2015-12-06
    • 1970-01-01
    • 1970-01-01
    • 2016-12-03
    • 2014-01-31
    • 2018-10-01
    相关资源
    最近更新 更多